mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.0.0201: completion of highlight groups includes cleared names
Problem: When completing a group name for a highlight or syntax command cleared groups are included. Solution: Skip groups that have been cleared.
This commit is contained in:
parent
58f60ca2fc
commit
d61e8aaae5
13
src/syntax.c
13
src/syntax.c
@ -22,6 +22,7 @@ struct hl_group
|
|||||||
{
|
{
|
||||||
char_u *sg_name; /* highlight group name */
|
char_u *sg_name; /* highlight group name */
|
||||||
char_u *sg_name_u; /* uppercase of sg_name */
|
char_u *sg_name_u; /* uppercase of sg_name */
|
||||||
|
int sg_cleared; /* "hi clear" was used */
|
||||||
/* for normal terminals */
|
/* for normal terminals */
|
||||||
int sg_term; /* "term=" highlighting attributes */
|
int sg_term; /* "term=" highlighting attributes */
|
||||||
char_u *sg_start; /* terminal string for start highl */
|
char_u *sg_start; /* terminal string for start highl */
|
||||||
@ -7327,6 +7328,7 @@ do_highlight(
|
|||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
HL_TABLE()[from_id - 1].sg_scriptID = current_SID;
|
HL_TABLE()[from_id - 1].sg_scriptID = current_SID;
|
||||||
#endif
|
#endif
|
||||||
|
HL_TABLE()[from_id - 1].sg_cleared = FALSE;
|
||||||
redraw_all_later(SOME_VALID);
|
redraw_all_later(SOME_VALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8034,6 +8036,7 @@ do_highlight(
|
|||||||
error = TRUE;
|
error = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
HL_TABLE()[idx].sg_cleared = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When highlighting has been given for a group, don't link it.
|
* When highlighting has been given for a group, don't link it.
|
||||||
@ -8171,6 +8174,8 @@ hl_has_settings(int idx, int check_link)
|
|||||||
static void
|
static void
|
||||||
highlight_clear(int idx)
|
highlight_clear(int idx)
|
||||||
{
|
{
|
||||||
|
HL_TABLE()[idx].sg_cleared = TRUE;
|
||||||
|
|
||||||
HL_TABLE()[idx].sg_term = 0;
|
HL_TABLE()[idx].sg_term = 0;
|
||||||
vim_free(HL_TABLE()[idx].sg_start);
|
vim_free(HL_TABLE()[idx].sg_start);
|
||||||
HL_TABLE()[idx].sg_start = NULL;
|
HL_TABLE()[idx].sg_start = NULL;
|
||||||
@ -9958,7 +9963,13 @@ get_highlight_name(expand_T *xp UNUSED, int idx)
|
|||||||
&& include_link != 0)
|
&& include_link != 0)
|
||||||
return (char_u *)"clear";
|
return (char_u *)"clear";
|
||||||
#endif
|
#endif
|
||||||
if (idx < 0 || idx >= highlight_ga.ga_len)
|
if (idx < 0)
|
||||||
|
return NULL;
|
||||||
|
/* Items are never removed from the table, skip the ones that were cleared.
|
||||||
|
*/
|
||||||
|
while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
|
||||||
|
++idx;
|
||||||
|
if (idx >= highlight_ga.ga_len)
|
||||||
return NULL;
|
return NULL;
|
||||||
return HL_TABLE()[idx].sg_name;
|
return HL_TABLE()[idx].sg_name;
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,12 @@ func Test_syntax_completion()
|
|||||||
call feedkeys(":syn sync \<C-A>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":syn sync \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_equal('"syn sync ccomment clear fromstart linebreaks= linecont lines= match maxlines= minlines= region', @:)
|
call assert_equal('"syn sync ccomment clear fromstart linebreaks= linecont lines= match maxlines= minlines= region', @:)
|
||||||
|
|
||||||
|
" Check that clearing "Aap" avoids it showing up before Boolean.
|
||||||
|
hi Aap ctermfg=blue
|
||||||
|
call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
|
call assert_match('^"syn list Aap Boolean Character ', @:)
|
||||||
|
hi clear Aap
|
||||||
|
|
||||||
call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_match('^"syn list Boolean Character ', @:)
|
call assert_match('^"syn list Boolean Character ', @:)
|
||||||
|
|
||||||
@ -192,11 +198,11 @@ func Test_syntax_arg_skipped()
|
|||||||
call assert_match('conceal off', execute('syntax conceal'))
|
call assert_match('conceal off', execute('syntax conceal'))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
syntax region Tar start=/</ end=/>/
|
syntax region Bar start=/</ end=/>/
|
||||||
if 0
|
if 0
|
||||||
syntax region NotTest start=/</ end=/>/ contains=@Spell
|
syntax region NotTest start=/</ end=/>/ contains=@Spell
|
||||||
endif
|
endif
|
||||||
call assert_match('Tar', execute('syntax'))
|
call assert_match('Bar', execute('syntax'))
|
||||||
call assert_notmatch('NotTest', execute('syntax'))
|
call assert_notmatch('NotTest', execute('syntax'))
|
||||||
call assert_notmatch('Spell', execute('syntax'))
|
call assert_notmatch('Spell', execute('syntax'))
|
||||||
|
|
||||||
@ -206,6 +212,8 @@ func Test_syntax_arg_skipped()
|
|||||||
syntax rest
|
syntax rest
|
||||||
endif
|
endif
|
||||||
call assert_equal(a, execute('hi Foo'))
|
call assert_equal(a, execute('hi Foo'))
|
||||||
|
hi clear Bar
|
||||||
|
hi clear Foo
|
||||||
|
|
||||||
set ft=tags
|
set ft=tags
|
||||||
syn off
|
syn off
|
||||||
@ -298,7 +306,9 @@ endfunc
|
|||||||
|
|
||||||
func Test_invalid_arg()
|
func Test_invalid_arg()
|
||||||
call assert_fails('syntax case asdf', 'E390:')
|
call assert_fails('syntax case asdf', 'E390:')
|
||||||
call assert_fails('syntax conceal asdf', 'E390:')
|
if has('conceal')
|
||||||
|
call assert_fails('syntax conceal asdf', 'E390:')
|
||||||
|
endif
|
||||||
call assert_fails('syntax spell asdf', 'E390:')
|
call assert_fails('syntax spell asdf', 'E390:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@ -313,13 +323,15 @@ endfunc
|
|||||||
|
|
||||||
func Test_syn_clear()
|
func Test_syn_clear()
|
||||||
syntax keyword Foo foo
|
syntax keyword Foo foo
|
||||||
syntax keyword Tar tar
|
syntax keyword Bar tar
|
||||||
call assert_match('Foo', execute('syntax'))
|
call assert_match('Foo', execute('syntax'))
|
||||||
call assert_match('Tar', execute('syntax'))
|
call assert_match('Bar', execute('syntax'))
|
||||||
syn clear Foo
|
syn clear Foo
|
||||||
call assert_notmatch('Foo', execute('syntax'))
|
call assert_notmatch('Foo', execute('syntax'))
|
||||||
call assert_match('Tar', execute('syntax'))
|
call assert_match('Bar', execute('syntax'))
|
||||||
syn clear Foo Tar
|
syn clear Foo Bar
|
||||||
call assert_notmatch('Foo', execute('syntax'))
|
call assert_notmatch('Foo', execute('syntax'))
|
||||||
call assert_notmatch('Tar', execute('syntax'))
|
call assert_notmatch('Bar', execute('syntax'))
|
||||||
|
hi clear Foo
|
||||||
|
hi clear Bar
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
201,
|
||||||
/**/
|
/**/
|
||||||
200,
|
200,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user