Skip to content

Commit 9115c61

Browse files
committed
patch 8.1.2156: first character after Tab is not highlighted
Problem: First character after Tab is not highlighted. Solution: Remember the syntax attribute for a column.
1 parent a381773 commit 9115c61

4 files changed

Lines changed: 23 additions & 11 deletions

File tree

src/drawline.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ win_line(
289289
#ifdef FEAT_SYN_HL
290290
int vcol_save_attr = 0; // saved attr for 'cursorcolumn'
291291
int syntax_attr = 0; // attributes desired by syntax
292+
int prev_syntax_col = -1; // column of prev_syntax_attr
293+
int prev_syntax_attr = 0; // syntax_attr at prev_syntax_col
292294
int has_syntax = FALSE; // this buffer has syntax highl.
293295
int save_did_emsg;
294296
int draw_color_col = FALSE; // highlight colorcolumn
@@ -1414,12 +1416,20 @@ win_line(
14141416
did_emsg = FALSE;
14151417

14161418
v = (long)(ptr - line);
1417-
can_spell = TRUE;
1418-
syntax_attr = get_syntax_attr((colnr_T)v,
1419+
if (v == prev_syntax_col)
1420+
// at same column again
1421+
syntax_attr = prev_syntax_attr;
1422+
else
1423+
{
1424+
can_spell = TRUE;
1425+
syntax_attr = get_syntax_attr((colnr_T)v,
14191426
# ifdef FEAT_SPELL
14201427
has_spell ? &can_spell :
14211428
# endif
14221429
NULL, FALSE);
1430+
prev_syntax_col = v;
1431+
prev_syntax_attr = syntax_attr;
1432+
}
14231433

14241434
// combine syntax attribute with 'wincolor'
14251435
if (syntax_attr != 0 && win_attr != 0)

src/testdir/dumps/Test_syntax_c_01.dump

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
|}| @73
1313
@3|s+0#00e0003&|t|a|t|i|c| +0#0000000&|v+0#00e0003&|o|i|d| +0#0000000&@60
1414
|m|y|F|u|n|c|t|i|o|n|(|c+0#00e0003&|o|n|s|t| +0#0000000&|d+0#00e0003&|o|u|b|l|e| +0#0000000&|c|o|u|n|t|,| |s+0#00e0003&|t|r|u|c|t| +0#0000000&|n|o|t|h|i|n|g|,| |l+0#00e0003&|o|n|g| +0#0000000&|t|h|e|r|e|)| |{| @14
15-
@2|/+0#0000e05&@1| |1+0#e000002&|2|3|:+0#0000e05&| |n|o|t|h|i|n|g| |t|o| |r|e|a|d| |h|e|r|e| +0#0000000&@44
16-
@2|f+0#af5f00255&|o|r| +0#0000000&|(|i+0#00e0003&|n|t| +0#0000000&|i| |=| |0+0#e000002&|;+0#0000000&| |i| |<| |c|o|u|n|t|;| |+@1|i|)| |{| @39
17-
@4|b+0#af5f00255&|r|e|a|k|;+0#0000000&| @64
18-
@2|}| @71
15+
@1| +0#0000e05&@6|/@1| |1+0#e000002&|2|3|:+0#0000e05&| |n|o|t|h|i|n|g| |t|o| |r|e|a|d| |h|e|r|e| +0#0000000&@38
16+
@1| +0#af5f00255&@6|f|o|r| +0#0000000&|(|i+0#00e0003&|n|t| +0#0000000&|i| |=| |0+0#e000002&|;+0#0000000&| |i| |<| |c|o|u|n|t|;| |+@1|i|)| |{| @33
17+
@11|b+0#af5f00255&|r|e|a|k|;+0#0000000&| @57
18+
@8|}| @65
1919
|}| @73
20-
|"|X|t|e|s|t|.|c|"| |1|9|L|,| |3|6|4|C| @37|1|,|1| @10|A|l@1|
20+
|"|X|t|e|s|t|.|c|"| |1|9|L|,| |3|6|1|C| @37|1|,|1| @10|A|l@1|

src/testdir/test_syntax.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,10 @@ func Test_syntax_c()
551551
\ '}',
552552
\ ' static void',
553553
\ 'myFunction(const double count, struct nothing, long there) {',
554-
\ ' // 123: nothing to read here',
555-
\ ' for (int i = 0; i < count; ++i) {',
556-
\ ' break;',
557-
\ ' }',
554+
\ "\t// 123: nothing to read here",
555+
\ "\tfor (int i = 0; i < count; ++i) {",
556+
\ "\t break;",
557+
\ "\t}",
558558
\ '}',
559559
\ ], 'Xtest.c')
560560

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ static char *(features[]) =
753753

754754
static int included_patches[] =
755755
{ /* Add new patch number below this line */
756+
/**/
757+
2156,
756758
/**/
757759
2155,
758760
/**/

0 commit comments

Comments
 (0)