mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.0220: highlight completion misses some values #8013
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.
15eedf1d62
This commit is contained in:
parent
544cef0155
commit
b615192a37
@ -7762,10 +7762,18 @@ static void highlight_list_two(int cnt, int attr)
|
|||||||
* Function given to ExpandGeneric() to obtain the list of group names.
|
* Function given to ExpandGeneric() to obtain the list of group names.
|
||||||
* Also used for synIDattr() function.
|
* Also used for synIDattr() function.
|
||||||
*/
|
*/
|
||||||
const char *get_highlight_name(expand_T *const xp, const int idx)
|
const char *get_highlight_name(expand_T *const xp, int idx)
|
||||||
FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
// TODO(justinmk): 'xp' is unused
|
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 && include_none != 0) {
|
if (idx == highlight_ga.ga_len && include_none != 0) {
|
||||||
return "none";
|
return "none";
|
||||||
} else if (idx == highlight_ga.ga_len + include_none
|
} else if (idx == highlight_ga.ga_len + include_none
|
||||||
@ -7777,20 +7785,10 @@ const char *get_highlight_name(expand_T *const xp, const int idx)
|
|||||||
} else if (idx == highlight_ga.ga_len + include_none + include_default + 1
|
} else if (idx == highlight_ga.ga_len + include_none + include_default + 1
|
||||||
&& include_link != 0) {
|
&& include_link != 0) {
|
||||||
return "clear";
|
return "clear";
|
||||||
} else if (idx < 0) {
|
} else if (idx >= highlight_ga.ga_len) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
return (const char *)HL_TABLE()[idx].sg_name;
|
||||||
// Items are never removed from the table, skip the ones that were cleared.
|
|
||||||
int current_idx = idx;
|
|
||||||
while (current_idx < highlight_ga.ga_len
|
|
||||||
&& HL_TABLE()[current_idx].sg_cleared) {
|
|
||||||
current_idx++;
|
|
||||||
}
|
|
||||||
if (current_idx >= highlight_ga.ga_len) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return (const char *)HL_TABLE()[current_idx].sg_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
color_name_table_T color_name_table[] = {
|
color_name_table_T color_name_table[] = {
|
||||||
|
@ -46,8 +46,34 @@ func Test_map_completion()
|
|||||||
call assert_equal('"map <silent> <special>', getreg(':'))
|
call assert_equal('"map <silent> <special>', getreg(':'))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_match_completion()
|
||||||
|
if !has('cmdline_compl')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
hi Aardig ctermfg=green
|
||||||
|
call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt')
|
||||||
|
call assert_equal('"match Aardig', getreg(':'))
|
||||||
|
call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt')
|
||||||
|
call assert_equal('"match none', getreg(':'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_highlight_completion()
|
||||||
|
if !has('cmdline_compl')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
hi Aardig ctermfg=green
|
||||||
|
call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt')
|
||||||
|
call assert_equal('"hi Aardig', getreg(':'))
|
||||||
|
call feedkeys(":hi li\<S-Tab>\<Home>\"\<CR>", 'xt')
|
||||||
|
call assert_equal('"hi link', getreg(':'))
|
||||||
|
call feedkeys(":hi d\<S-Tab>\<Home>\"\<CR>", 'xt')
|
||||||
|
call assert_equal('"hi default', getreg(':'))
|
||||||
|
call feedkeys(":hi c\<S-Tab>\<Home>\"\<CR>", 'xt')
|
||||||
|
call assert_equal('"hi clear', getreg(':'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_expr_completion()
|
func Test_expr_completion()
|
||||||
if !(has('cmdline_compl') && has('eval'))
|
if !has('cmdline_compl')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
for cmd in [
|
for cmd in [
|
||||||
@ -286,17 +312,17 @@ func Test_paste_in_cmdline()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_remove_char_in_cmdline()
|
func Test_remove_char_in_cmdline()
|
||||||
call feedkeys(":abc def\<S-Left>\<Del>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":abc def\<S-Left>\<Del>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_equal('"abc ef', @:)
|
call assert_equal('"abc ef', @:)
|
||||||
|
|
||||||
call feedkeys(":abc def\<S-Left>\<BS>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":abc def\<S-Left>\<BS>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_equal('"abcdef', @:)
|
call assert_equal('"abcdef', @:)
|
||||||
|
|
||||||
call feedkeys(":abc def ghi\<S-Left>\<C-W>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":abc def ghi\<S-Left>\<C-W>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_equal('"abc ghi', @:)
|
call assert_equal('"abc ghi', @:)
|
||||||
|
|
||||||
call feedkeys(":abc def\<S-Left>\<C-U>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":abc def\<S-Left>\<C-U>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_equal('"def', @:)
|
call assert_equal('"def', @:)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_illegal_address1()
|
func Test_illegal_address1()
|
||||||
|
Loading…
Reference in New Issue
Block a user