aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/insexpand.c2
-rw-r--r--src/nvim/popupmenu.c5
-rw-r--r--test/functional/ui/popupmenu_spec.lua28
-rw-r--r--test/old/testdir/test_popup.vim21
4 files changed, 53 insertions, 3 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 0a25b72451..ded5c6e3c3 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -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
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index 2d3c128de1..8608a2c866 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -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;
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index fac863ead0..a1a21eb317 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -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
diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim
index 6c14fb3a6e..bfd81ad0a9 100644
--- a/test/old/testdir/test_popup.vim
+++ b/test/old/testdir/test_popup.vim
@@ -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