mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.1.0496: matched text is highlighted case-sensitively
Problem: matched text is highlighted case-sensitively
Solution: use MB_STRNICMP, update highlighting when the base changes
(glepnir)
fixes: vim/vim#15021
closes: vim/vim#15023
f189138b39
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
parent
c429c5f86f
commit
c2491fbab4
@ -1397,7 +1397,7 @@ bool compl_match_curr_select(int selected)
|
||||
/// Get current completion leader
|
||||
char *ins_compl_leader(void)
|
||||
{
|
||||
return compl_leader;
|
||||
return compl_leader != NULL ? compl_leader : compl_orig_text;
|
||||
}
|
||||
|
||||
/// Add any identifiers that match the given pattern "pat" in the list of
|
||||
|
@ -448,7 +448,8 @@ static int *pum_compute_text_attrs(char *text, hlf_T hlf)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *leader = State == MODE_CMDLINE ? cmdline_compl_pattern() : ins_compl_leader();
|
||||
char *leader = State == MODE_CMDLINE ? cmdline_compl_pattern()
|
||||
: ins_compl_leader();
|
||||
if (leader == NULL || *leader == NUL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -464,7 +465,7 @@ static int *pum_compute_text_attrs(char *text, hlf_T hlf)
|
||||
if (in_fuzzy) {
|
||||
ga = fuzzy_match_str_with_pos(text, leader);
|
||||
} else {
|
||||
matched_start = strncmp(text, leader, leader_len) == 0;
|
||||
matched_start = mb_strnicmp(text, leader, leader_len) == 0;
|
||||
}
|
||||
|
||||
const char *ptr = text;
|
||||
|
@ -4739,6 +4739,20 @@ describe('builtin popupmenu', function()
|
||||
\ { 'word': '你可好吗' },
|
||||
\]}
|
||||
endfunc
|
||||
|
||||
func Comp()
|
||||
let col = col('.')
|
||||
if getline('.') == 'f'
|
||||
let col -= 1
|
||||
endif
|
||||
call complete(col, [
|
||||
\ #{word: "foo", icase: 1},
|
||||
\ #{word: "Foobar", icase: 1},
|
||||
\ #{word: "fooBaz", icase: 1},
|
||||
\])
|
||||
return ''
|
||||
endfunc
|
||||
|
||||
set omnifunc=Omni_test
|
||||
set completeopt=menu,noinsert,fuzzy
|
||||
hi PmenuMatchSel guifg=Blue guibg=Grey
|
||||
@ -4878,6 +4892,20 @@ describe('builtin popupmenu', function()
|
||||
]])
|
||||
feed('<C-E><Esc>')
|
||||
command('set norightleft')
|
||||
|
||||
feed('S<C-R>=Comp()<CR>f')
|
||||
screen:expect([[
|
||||
f^ |
|
||||
{ms:f}{s:oo }{1: }|
|
||||
{mn:F}{n:oobar }{1: }|
|
||||
{mn:f}{n:ooBaz }{1: }|
|
||||
{1:~ }|*15
|
||||
{2:-- INSERT --} |
|
||||
]])
|
||||
feed('o<BS><C-R>=Comp()<CR>')
|
||||
screen:expect_unchanged(true)
|
||||
|
||||
feed('<C-E><Esc>')
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
@ -1407,6 +1407,20 @@ func Test_pum_highlights_match()
|
||||
\ { 'word': '你可好吗' },
|
||||
\]}
|
||||
endfunc
|
||||
|
||||
func Comp()
|
||||
let col = col('.')
|
||||
if getline('.') == 'f'
|
||||
let col -= 1
|
||||
endif
|
||||
call complete(col, [
|
||||
\ #{word: "foo", icase: 1},
|
||||
\ #{word: "Foobar", icase: 1},
|
||||
\ #{word: "fooBaz", icase: 1},
|
||||
\])
|
||||
return ''
|
||||
endfunc
|
||||
|
||||
set omnifunc=Omni_test
|
||||
set completeopt=menu,noinsert,fuzzy
|
||||
hi PmenuMatchSel ctermfg=6 ctermbg=7
|
||||
@ -1470,7 +1484,14 @@ func Test_pum_highlights_match()
|
||||
call term_sendkeys(buf, ":set norightleft\<CR>")
|
||||
endif
|
||||
|
||||
call term_sendkeys(buf, "S\<C-R>=Comp()\<CR>f")
|
||||
call VerifyScreenDump(buf, 'Test_pum_highlights_09', {})
|
||||
call term_sendkeys(buf, "o\<BS>\<C-R>=Comp()\<CR>")
|
||||
call VerifyScreenDump(buf, 'Test_pum_highlights_09', {})
|
||||
|
||||
call term_sendkeys(buf, "\<C-E>\<Esc>")
|
||||
call TermWait(buf)
|
||||
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user