Skip to content

Commit 15eedf1

Browse files
committed
patch 8.0.0220: completion of highlight names misses a few values
Problem: Completion for :match does not show "none" and other missing highlight names. Solution: Skip over cleared entries before checking the index to be at the end.
1 parent 7a40ea2 commit 15eedf1

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

src/syntax.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9956,6 +9956,13 @@ highlight_list_two(int cnt, int attr)
99569956
char_u *
99579957
get_highlight_name(expand_T *xp UNUSED, int idx)
99589958
{
9959+
if (idx < 0)
9960+
return NULL;
9961+
/* Items are never removed from the table, skip the ones that were cleared.
9962+
*/
9963+
while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
9964+
++idx;
9965+
99599966
#ifdef FEAT_CMDL_COMPL
99609967
if (idx == highlight_ga.ga_len && include_none != 0)
99619968
return (char_u *)"none";
@@ -9968,12 +9975,6 @@ get_highlight_name(expand_T *xp UNUSED, int idx)
99689975
&& include_link != 0)
99699976
return (char_u *)"clear";
99709977
#endif
9971-
if (idx < 0)
9972-
return NULL;
9973-
/* Items are never removed from the table, skip the ones that were cleared.
9974-
*/
9975-
while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
9976-
++idx;
99779978
if (idx >= highlight_ga.ga_len)
99789979
return NULL;
99799980
return HL_TABLE()[idx].sg_name;

src/testdir/test_cmdline.vim

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,34 @@ func Test_complete_wildmenu()
2525
set nowildmenu
2626
endfunc
2727

28+
func Test_match_completion()
29+
if !has('cmdline_compl')
30+
return
31+
endif
32+
hi Aardig ctermfg=green
33+
call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt')
34+
call assert_equal('"match Aardig', getreg(':'))
35+
call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt')
36+
call assert_equal('"match none', getreg(':'))
37+
endfunc
38+
39+
func Test_highlight_completion()
40+
if !has('cmdline_compl')
41+
return
42+
endif
43+
hi Aardig ctermfg=green
44+
call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt')
45+
call assert_equal('"hi Aardig', getreg(':'))
46+
call feedkeys(":hi li\<S-Tab>\<Home>\"\<CR>", 'xt')
47+
call assert_equal('"hi link', getreg(':'))
48+
call feedkeys(":hi d\<S-Tab>\<Home>\"\<CR>", 'xt')
49+
call assert_equal('"hi default', getreg(':'))
50+
call feedkeys(":hi c\<S-Tab>\<Home>\"\<CR>", 'xt')
51+
call assert_equal('"hi clear', getreg(':'))
52+
endfunc
53+
2854
func Test_expr_completion()
29-
if !(has('cmdline_compl') && has('eval'))
55+
if !has('cmdline_compl')
3056
return
3157
endif
3258
for cmd in [

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
220,
767769
/**/
768770
219,
769771
/**/

0 commit comments

Comments
 (0)