diff src/syntax.c @ 11902:35d7459251fd v8.0.0831

patch 8.0.0831: with 8 colors the bold attribute is not set properly commit https://github.com/vim/vim/commit/12d853fae1fc37c33874b5cf1e40a2dfaf04268c Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 1 18:04:04 2017 +0200 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 https://github.com/vim/vim/issues/1901)
author Christian Brabandt <cb@256bit.org>
date Tue, 01 Aug 2017 18:15:05 +0200
parents 318ae82d8ba4
children e1b34958f118
line wrap: on
line diff
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -7276,9 +7276,11 @@ static int color_numbers_8[28] = {0, 4, 
 /*
  * Lookup the "cterm" value to be used for color with index "idx" in
  * color_names[].
+ * "boldp" will be set to TRUE or FALSE for a foreground color when using 8
+ * colors, otherwise it will be unchanged.
  */
     int
-lookup_color(int idx, int foreground)
+lookup_color(int idx, int foreground, int *boldp)
 {
     int		color = color_numbers_16[idx];
     char_u	*p;
@@ -7300,12 +7302,9 @@ lookup_color(int idx, int 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 = TRUE;
 	    else
-		HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
+		*boldp = FALSE;
 	}
 	color &= 7;	/* truncate to 8 colors */
     }
@@ -7837,6 +7836,8 @@ do_highlight(
 	    }
 	    else
 	    {
+		int bold = MAYBE;
+
 #if defined(__QNXNTO__)
 		static int *color_numbers_8_qansi = color_numbers_8;
 		/* On qnx, the 8 & 16 color arrays are the same */
@@ -7857,7 +7858,17 @@ do_highlight(
 		    break;
 		}
 
-		color = lookup_color(i, key[5] == 'F');
+		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 == TRUE)
+		{
+		    HL_TABLE()[idx].sg_cterm |= HL_BOLD;
+		    HL_TABLE()[idx].sg_cterm_bold = TRUE;
+		}
+		else if (bold == FALSE)
+		    HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
 	    }
 
 	    /* Add one to the argument, to avoid zero.  Zero is used for