Skip to content

Commit 1a53ab6

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 46753d9 + 980128c commit 1a53ab6

File tree

9 files changed

+41
-14
lines changed

9 files changed

+41
-14
lines changed

src/create_cmdidxs.pl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99
# Script should be run every time new Ex commands are added in Vim,
1010
# from the src/vim directory, since it reads commands from "ex_cmds.h".
1111

12+
use strict;
13+
1214
# Find the list of Vim commands from cmdnames[] table in ex_cmds.h
1315
my @cmds;
14-
my @skipped;
16+
my $skipped_cmds;
1517
open(IN, "< ex_cmds.h") or die "can't open ex_cmds.h: $!\n";
1618
while (<IN>) {
1719
if (/^EX\(CMD_\S*,\s*"([a-z][^"]*)"/) {
18-
push (@cmds, $1);
20+
push @cmds, $1;
1921
} elsif (/^EX\(CMD_/) {
20-
push (@skipped, $1);
22+
++$skipped_cmds;
2123
}
2224
}
2325

@@ -68,7 +70,6 @@
6870
}
6971
print "};\n",
7072
"\n",
71-
"static int command_count = ", $#cmds + $#skipped + 2 , ";\n",
73+
"static const int command_count = ", scalar(@cmds) + $skipped_cmds, ";\n",
7274
"\n",
7375
"/* End of automatically generated code by create_cmdidxs.pl */\n";
74-

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11773,7 +11773,7 @@ f_synIDattr(typval_T *argvars UNUSED, typval_T *rettv)
1177311773
break;
1177411774

1177511775
case 'n': /* name */
11776-
p = get_highlight_name(NULL, id - 1);
11776+
p = get_highlight_name_ext(NULL, id - 1, FALSE);
1177711777
break;
1177811778

1177911779
case 'r': /* reverse */

src/ex_cmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7962,7 +7962,7 @@ sign_list_defined(sign_T *sp)
79627962
if (sp->sn_line_hl > 0)
79637963
{
79647964
MSG_PUTS(" linehl=");
7965-
p = get_highlight_name(NULL, sp->sn_line_hl - 1);
7965+
p = get_highlight_name_ext(NULL, sp->sn_line_hl - 1, FALSE);
79667966
if (p == NULL)
79677967
MSG_PUTS("NONE");
79687968
else
@@ -7971,7 +7971,7 @@ sign_list_defined(sign_T *sp)
79717971
if (sp->sn_text_hl > 0)
79727972
{
79737973
MSG_PUTS(" texthl=");
7974-
p = get_highlight_name(NULL, sp->sn_text_hl - 1);
7974+
p = get_highlight_name_ext(NULL, sp->sn_text_hl - 1, FALSE);
79757975
if (p == NULL)
79767976
MSG_PUTS("NONE");
79777977
else

src/ex_docmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ static const unsigned char cmdidxs2[26][26] =
573573
/* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }
574574
};
575575

576-
static int command_count = 541;
576+
static const int command_count = 541;
577577

578578
/* End of automatically generated code by create_cmdidxs.pl */
579579

src/proto/syntax.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ void highlight_gui_started(void);
5252
int highlight_changed(void);
5353
void set_context_in_highlight_cmd(expand_T *xp, char_u *arg);
5454
char_u *get_highlight_name(expand_T *xp, int idx);
55+
char_u *get_highlight_name_ext(expand_T *xp, int idx, int skip_cleared);
5556
void free_highlight_fonts(void);
5657
/* vim: set ft=c : */

src/syntax.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9950,17 +9950,27 @@ highlight_list_two(int cnt, int attr)
99509950
|| defined(FEAT_SIGNS) || defined(PROTO)
99519951
/*
99529952
* Function given to ExpandGeneric() to obtain the list of group names.
9953-
* Also used for synIDattr() function.
99549953
*/
99559954
char_u *
99569955
get_highlight_name(expand_T *xp UNUSED, int idx)
9956+
{
9957+
return get_highlight_name_ext(xp, idx, TRUE);
9958+
}
9959+
9960+
/*
9961+
* Obtain a highlight group name.
9962+
* When "skip_cleared" is TRUE don't return a cleared entry.
9963+
*/
9964+
char_u *
9965+
get_highlight_name_ext(expand_T *xp UNUSED, int idx, int skip_cleared)
99579966
{
99589967
if (idx < 0)
99599968
return NULL;
9960-
/* Items are never removed from the table, skip the ones that were cleared.
9961-
*/
9962-
while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
9963-
++idx;
9969+
9970+
/* Items are never removed from the table, skip the ones that were
9971+
* cleared. */
9972+
if (skip_cleared && idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
9973+
return (char_u *)"";
99649974

99659975
#ifdef FEAT_CMDL_COMPL
99669976
if (idx == highlight_ga.ga_len && include_none != 0)

src/testdir/test_cmdline.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ func Test_highlight_completion()
7171
call assert_equal('"hi default', getreg(':'))
7272
call feedkeys(":hi c\<S-Tab>\<Home>\"\<CR>", 'xt')
7373
call assert_equal('"hi clear', getreg(':'))
74+
75+
" A cleared group does not show up in completions.
76+
hi Anders ctermfg=green
77+
call assert_equal(['Aardig', 'Anders'], getcompletion('A', 'highlight'))
78+
hi clear Aardig
79+
call assert_equal(['Anders'], getcompletion('A', 'highlight'))
80+
hi clear Anders
81+
call assert_equal([], getcompletion('A', 'highlight'))
7482
endfunc
7583

7684
func Test_expr_completion()

src/testdir/test_syntax.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,16 @@ func Test_syn_clear()
326326
syntax keyword Bar tar
327327
call assert_match('Foo', execute('syntax'))
328328
call assert_match('Bar', execute('syntax'))
329+
call assert_equal('Foo', synIDattr(hlID("Foo"), "name"))
329330
syn clear Foo
330331
call assert_notmatch('Foo', execute('syntax'))
331332
call assert_match('Bar', execute('syntax'))
333+
call assert_equal('Foo', synIDattr(hlID("Foo"), "name"))
332334
syn clear Foo Bar
333335
call assert_notmatch('Foo', execute('syntax'))
334336
call assert_notmatch('Bar', execute('syntax'))
335337
hi clear Foo
338+
call assert_equal('Foo', synIDattr(hlID("Foo"), "name"))
336339
hi clear Bar
337340
endfunc
338341

src/version.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,10 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
514,
784+
/**/
785+
513,
782786
/**/
783787
512,
784788
/**/

0 commit comments

Comments
 (0)