aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-07-14 01:43:48 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-07-29 07:52:45 -0400
commit0c0318f8a7ccbf1b286a4c52fefc168534ff7f5e (patch)
treecae2695a135732a09f5a352fdb5f4b2f481c55eb
parent5af90e2ee73efd156d269b9beba6e6d572dba2b7 (diff)
downloadrneovim-0c0318f8a7ccbf1b286a4c52fefc168534ff7f5e.tar.gz
rneovim-0c0318f8a7ccbf1b286a4c52fefc168534ff7f5e.tar.bz2
rneovim-0c0318f8a7ccbf1b286a4c52fefc168534ff7f5e.zip
vim-patch:8.0.0831: with 8 colors the bold attribute is not set properly
Problem: With 8 colors the bold attribute is not set properly. Solution: Move setting HL_TABLE() out of lookup_color. (closes vim/vim#1901) https://github.com/vim/vim/commit/12d853fae1fc37c33874b5cf1e40a2dfaf04268c Use TriState on lookup_color() to avoid 'NOLINT' comments.
-rw-r--r--src/nvim/syntax.c21
-rw-r--r--src/nvim/syntax.h1
2 files changed, 17 insertions, 5 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 6668852e0e..86ce259a29 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -6435,7 +6435,9 @@ static int color_numbers_8[28] = { 0, 4, 2, 6,
// Lookup the "cterm" value to be used for color with index "idx" in
// color_names[].
-int lookup_color(const int idx, const bool foreground)
+// "boldp" will be set to TRUE or FALSE for a foreground color when using 8
+// colors, otherwise it will be unchanged.
+int lookup_color(const int idx, const bool foreground, TriState *const boldp)
{
int color = color_numbers_16[idx];
@@ -6451,10 +6453,9 @@ int lookup_color(const int idx, const bool foreground)
// set/reset bold attribute to get light foreground
// colors (on some terminals, e.g. "linux")
if (color & 8) {
- HL_TABLE()[idx].sg_cterm |= HL_BOLD;
- HL_TABLE()[idx].sg_cterm_bold = true;
+ *boldp = kTrue;
} else {
- HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
+ *boldp = kFalse;
}
}
color &= 7; // truncate to 8 colors
@@ -6793,7 +6794,17 @@ void do_highlight(const char *line, const bool forceit, const bool init)
break;
}
- color = lookup_color(i, key[5] == 'F');
+ TriState bold = kNone;
+ color = lookup_color(i, key[5] == 'F', &bold);
+
+ // set/reset bold attribute to get light foreground
+ // colors (on some terminals, e.g. "linux")
+ if (bold == kTrue) {
+ HL_TABLE()[idx].sg_cterm |= HL_BOLD;
+ HL_TABLE()[idx].sg_cterm_bold = true;
+ } else if (bold == kFalse) {
+ HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
+ }
}
// Add one to the argument, to avoid zero. Zero is used for
// "NONE", then "color" is -1.
diff --git a/src/nvim/syntax.h b/src/nvim/syntax.h
index f8282955a6..9fbad74f64 100644
--- a/src/nvim/syntax.h
+++ b/src/nvim/syntax.h
@@ -3,6 +3,7 @@
#include <stdbool.h>
+#include "nvim/globals.h"
#include "nvim/buffer_defs.h"
#include "nvim/ex_cmds_defs.h"