mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
vim-patch:9.1.0830: using wrong highlight group for spaces for popupmenu (#31054)
Problem: using wrong highlight group for spaces for popupmenu
Solution: use original attribute instead of combined attributed
(glepnir)
closes: vim/vim#15978
bc10be7a40
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
parent
f3606416f0
commit
ed3fb1bb9a
@ -657,11 +657,14 @@ void pum_redraw(void)
|
|||||||
pum_align_order(order);
|
pum_align_order(order);
|
||||||
int basic_width = items_width_array[order[0]]; // first item width
|
int basic_width = items_width_array[order[0]]; // first item width
|
||||||
bool last_isabbr = order[2] == CPT_ABBR;
|
bool last_isabbr = order[2] == CPT_ABBR;
|
||||||
|
int orig_attr = -1;
|
||||||
|
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
int item_type = order[j];
|
int item_type = order[j];
|
||||||
hlf = hlfs[item_type];
|
hlf = hlfs[item_type];
|
||||||
attr = win_hl_attr(curwin, (int)hlf);
|
attr = win_hl_attr(curwin, (int)hlf);
|
||||||
int orig_attr = attr;
|
attr = hl_combine_attr(win_hl_attr(curwin, HLF_PNI), attr);
|
||||||
|
orig_attr = attr;
|
||||||
int user_abbr_hlattr = pum_array[idx].pum_user_abbr_hlattr;
|
int user_abbr_hlattr = pum_array[idx].pum_user_abbr_hlattr;
|
||||||
int user_kind_hlattr = pum_array[idx].pum_user_kind_hlattr;
|
int user_kind_hlattr = pum_array[idx].pum_user_kind_hlattr;
|
||||||
if (item_type == CPT_ABBR && user_abbr_hlattr > 0) {
|
if (item_type == CPT_ABBR && user_abbr_hlattr > 0) {
|
||||||
@ -670,7 +673,6 @@ void pum_redraw(void)
|
|||||||
if (item_type == CPT_KIND && user_kind_hlattr > 0) {
|
if (item_type == CPT_KIND && user_kind_hlattr > 0) {
|
||||||
attr = hl_combine_attr(attr, user_kind_hlattr);
|
attr = hl_combine_attr(attr, user_kind_hlattr);
|
||||||
}
|
}
|
||||||
attr = hl_combine_attr(win_hl_attr(curwin, HLF_PNI), attr);
|
|
||||||
int width = 0;
|
int width = 0;
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
p = pum_get_item(idx, item_type);
|
p = pum_get_item(idx, item_type);
|
||||||
@ -796,9 +798,9 @@ void pum_redraw(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pum_rl) {
|
if (pum_rl) {
|
||||||
grid_line_fill(col_off - pum_width + 1, grid_col + 1, schar_from_ascii(' '), attr);
|
grid_line_fill(col_off - pum_width + 1, grid_col + 1, schar_from_ascii(' '), orig_attr);
|
||||||
} else {
|
} else {
|
||||||
grid_line_fill(grid_col, col_off + pum_width, schar_from_ascii(' '), attr);
|
grid_line_fill(grid_col, col_off + pum_width, schar_from_ascii(' '), orig_attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pum_scrollbar > 0) {
|
if (pum_scrollbar > 0) {
|
||||||
|
@ -5190,10 +5190,18 @@ describe('builtin popupmenu', function()
|
|||||||
-- oldtest: Test_pum_user_abbr_hlgroup()
|
-- oldtest: Test_pum_user_abbr_hlgroup()
|
||||||
it('custom abbr_hlgroup override', function()
|
it('custom abbr_hlgroup override', function()
|
||||||
exec([[
|
exec([[
|
||||||
func CompleteFunc( findstart, base )
|
let s:var = 0
|
||||||
|
func CompleteFunc(findstart, base)
|
||||||
if a:findstart
|
if a:findstart
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
if s:var == 1
|
||||||
|
return {
|
||||||
|
\ 'words': [
|
||||||
|
\ { 'word': 'aword1', 'abbr_hlgroup': 'StrikeFake' },
|
||||||
|
\ { 'word': '你好', 'abbr_hlgroup': 'StrikeFake' },
|
||||||
|
\]}
|
||||||
|
endif
|
||||||
return {
|
return {
|
||||||
\ 'words': [
|
\ 'words': [
|
||||||
\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
|
\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
|
||||||
@ -5201,6 +5209,9 @@ describe('builtin popupmenu', function()
|
|||||||
\ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
|
\ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
|
||||||
\]}
|
\]}
|
||||||
endfunc
|
endfunc
|
||||||
|
func ChangeVar()
|
||||||
|
let s:var = 1
|
||||||
|
endfunc
|
||||||
set completeopt=menu
|
set completeopt=menu
|
||||||
set completefunc=CompleteFunc
|
set completefunc=CompleteFunc
|
||||||
|
|
||||||
@ -5243,6 +5254,17 @@ describe('builtin popupmenu', function()
|
|||||||
{2:-- }{5:match 2 of 3} |
|
{2:-- }{5:match 2 of 3} |
|
||||||
]])
|
]])
|
||||||
feed('<C-E><Esc>')
|
feed('<C-E><Esc>')
|
||||||
|
|
||||||
|
command('call ChangeVar()')
|
||||||
|
feed('S<C-X><C-U>')
|
||||||
|
screen:expect([[
|
||||||
|
aword1^ |
|
||||||
|
{ds:aword1}{s: }{1: }|
|
||||||
|
{dn:你好}{n: }{1: }|
|
||||||
|
{1:~ }|*16
|
||||||
|
{2:-- }{5:match 1 of 2} |
|
||||||
|
]])
|
||||||
|
feed('<C-E><Esc>')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- oldtest: Test_pum_user_kind_hlgroup()
|
-- oldtest: Test_pum_user_kind_hlgroup()
|
||||||
|
@ -1509,10 +1509,18 @@ endfunc
|
|||||||
func Test_pum_user_abbr_hlgroup()
|
func Test_pum_user_abbr_hlgroup()
|
||||||
CheckScreendump
|
CheckScreendump
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
func CompleteFunc( findstart, base )
|
let s:var = 0
|
||||||
|
func CompleteFunc(findstart, base)
|
||||||
if a:findstart
|
if a:findstart
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
if s:var == 1
|
||||||
|
return {
|
||||||
|
\ 'words': [
|
||||||
|
\ { 'word': 'aword1', 'abbr_hlgroup': 'StrikeFake' },
|
||||||
|
\ { 'word': '你好', 'abbr_hlgroup': 'StrikeFake' },
|
||||||
|
\]}
|
||||||
|
endif
|
||||||
return {
|
return {
|
||||||
\ 'words': [
|
\ 'words': [
|
||||||
\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
|
\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
|
||||||
@ -1520,6 +1528,9 @@ func Test_pum_user_abbr_hlgroup()
|
|||||||
\ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
|
\ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
|
||||||
\]}
|
\]}
|
||||||
endfunc
|
endfunc
|
||||||
|
func ChangeVar()
|
||||||
|
let s:var = 1
|
||||||
|
endfunc
|
||||||
set completeopt=menu
|
set completeopt=menu
|
||||||
set completefunc=CompleteFunc
|
set completefunc=CompleteFunc
|
||||||
|
|
||||||
@ -1547,13 +1558,20 @@ func Test_pum_user_abbr_hlgroup()
|
|||||||
call VerifyScreenDump(buf, 'Test_pum_highlights_14', {})
|
call VerifyScreenDump(buf, 'Test_pum_highlights_14', {})
|
||||||
call term_sendkeys(buf, "\<C-E>\<Esc>")
|
call term_sendkeys(buf, "\<C-E>\<Esc>")
|
||||||
|
|
||||||
|
call TermWait(buf)
|
||||||
|
call term_sendkeys(buf, ":call ChangeVar()\<CR>")
|
||||||
|
call TermWait(buf)
|
||||||
|
call term_sendkeys(buf, "S\<C-X>\<C-U>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_pum_highlights_17', {})
|
||||||
|
call term_sendkeys(buf, "\<C-E>\<Esc>")
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_pum_user_kind_hlgroup()
|
func Test_pum_user_kind_hlgroup()
|
||||||
CheckScreendump
|
CheckScreendump
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
func CompleteFunc( findstart, base )
|
func CompleteFunc(findstart, base)
|
||||||
if a:findstart
|
if a:findstart
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user