mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
vim-patch:9.1.1594: completion: search completion throws errors (#35198)
Problem: completion: search completion throws errors, wrong placement
of pum menu with 'imi'=1 (berggeist)
Solution: Fix those errors (Girish Palya)
fixes: vim/vim#17858
closes: vim/vim#17870
66467cf5d8
Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
@@ -4044,8 +4044,18 @@ static int copy_substring_from_pos(pos_T *start, pos_T *end, char **match, pos_T
|
|||||||
/// case sensitivity.
|
/// case sensitivity.
|
||||||
static bool is_regex_match(char *pat, char *str)
|
static bool is_regex_match(char *pat, char *str)
|
||||||
{
|
{
|
||||||
|
if (strcmp(pat, str) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
regmatch_T regmatch;
|
regmatch_T regmatch;
|
||||||
|
|
||||||
|
emsg_off++;
|
||||||
|
msg_silent++;
|
||||||
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
|
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
|
||||||
|
emsg_off--;
|
||||||
|
msg_silent--;
|
||||||
|
|
||||||
if (regmatch.regprog == NULL) {
|
if (regmatch.regprog == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -4054,7 +4064,11 @@ static bool is_regex_match(char *pat, char *str)
|
|||||||
regmatch.rm_ic = !pat_has_uppercase(pat);
|
regmatch.rm_ic = !pat_has_uppercase(pat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emsg_off++;
|
||||||
|
msg_silent++;
|
||||||
bool result = vim_regexec_nl(®match, str, (colnr_T)0);
|
bool result = vim_regexec_nl(®match, str, (colnr_T)0);
|
||||||
|
emsg_off--;
|
||||||
|
msg_silent--;
|
||||||
|
|
||||||
vim_regfree(regmatch.regprog);
|
vim_regfree(regmatch.regprog);
|
||||||
return result;
|
return result;
|
||||||
|
@@ -142,10 +142,10 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
// To keep the code simple, we only allow changing the
|
// To keep the code simple, we only allow changing the
|
||||||
// draw mode when the popup menu is not being displayed
|
// draw mode when the popup menu is not being displayed
|
||||||
pum_external = ui_has(kUIPopupmenu)
|
pum_external = ui_has(kUIPopupmenu)
|
||||||
|| (State == MODE_CMDLINE && ui_has(kUIWildmenu));
|
|| ((State & MODE_CMDLINE) && ui_has(kUIWildmenu));
|
||||||
}
|
}
|
||||||
|
|
||||||
pum_rl = State != MODE_CMDLINE && curwin->w_p_rl;
|
pum_rl = (State & MODE_CMDLINE) == 0 && curwin->w_p_rl;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
// Mark the pum as visible already here,
|
// Mark the pum as visible already here,
|
||||||
@@ -163,7 +163,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
pum_win_col_offset = 0;
|
pum_win_col_offset = 0;
|
||||||
|
|
||||||
// wildoptions=pum
|
// wildoptions=pum
|
||||||
if (State == MODE_CMDLINE) {
|
if (State & MODE_CMDLINE) {
|
||||||
pum_win_row = cmdline_win ? cmdline_win->w_wrow : ui_has(kUICmdline) ? 0 : cmdline_row;
|
pum_win_row = cmdline_win ? cmdline_win->w_wrow : ui_has(kUICmdline) ? 0 : cmdline_row;
|
||||||
cursor_col = (cmdline_win ? cmdline_win->w_config._cmdline_offset : 0) + cmd_startcol;
|
cursor_col = (cmdline_win ? cmdline_win->w_config._cmdline_offset : 0) + cmd_startcol;
|
||||||
cursor_col %= cmdline_win ? cmdline_win->w_view_width : Columns;
|
cursor_col %= cmdline_win ? cmdline_win->w_view_width : Columns;
|
||||||
@@ -257,7 +257,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
// pum above "pum_win_row"
|
// pum above "pum_win_row"
|
||||||
pum_above = true;
|
pum_above = true;
|
||||||
|
|
||||||
if (State == MODE_CMDLINE && target_win == NULL) {
|
if ((State & MODE_CMDLINE) && target_win == NULL) {
|
||||||
// For cmdline pum, no need for context lines unless target_win is set
|
// For cmdline pum, no need for context lines unless target_win is set
|
||||||
context_lines = 0;
|
context_lines = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -281,7 +281,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
// pum below "pum_win_row"
|
// pum below "pum_win_row"
|
||||||
pum_above = false;
|
pum_above = false;
|
||||||
|
|
||||||
if (State == MODE_CMDLINE && target_win == NULL) {
|
if ((State & MODE_CMDLINE) && target_win == NULL) {
|
||||||
// for cmdline pum, no need for context lines unless target_win is set
|
// for cmdline pum, no need for context lines unless target_win is set
|
||||||
context_lines = 0;
|
context_lines = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -437,7 +437,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
// room the window size will keep changing.
|
// room the window size will keep changing.
|
||||||
} while (pum_set_selected(selected, redo_count) && ++redo_count <= 2);
|
} while (pum_set_selected(selected, redo_count) && ++redo_count <= 2);
|
||||||
|
|
||||||
pum_grid.zindex = (State == MODE_CMDLINE) ? kZIndexCmdlinePopupMenu : kZIndexPopupMenu;
|
pum_grid.zindex = (State & MODE_CMDLINE) ? kZIndexCmdlinePopupMenu : kZIndexPopupMenu;
|
||||||
pum_redraw();
|
pum_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,15 +451,15 @@ static int *pum_compute_text_attrs(char *text, hlf_T hlf, int user_hlattr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *leader = State == MODE_CMDLINE ? cmdline_compl_pattern()
|
char *leader = (State & MODE_CMDLINE) ? cmdline_compl_pattern()
|
||||||
: ins_compl_leader();
|
: ins_compl_leader();
|
||||||
if (leader == NULL || *leader == NUL) {
|
if (leader == NULL || *leader == NUL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int *attrs = xmalloc(sizeof(int) * (size_t)vim_strsize(text));
|
int *attrs = xmalloc(sizeof(int) * (size_t)vim_strsize(text));
|
||||||
bool in_fuzzy = State == MODE_CMDLINE ? cmdline_compl_is_fuzzy()
|
bool in_fuzzy = (State & MODE_CMDLINE) ? cmdline_compl_is_fuzzy()
|
||||||
: (get_cot_flags() & kOptCotFlagFuzzy) != 0;
|
: (get_cot_flags() & kOptCotFlagFuzzy) != 0;
|
||||||
size_t leader_len = strlen(leader);
|
size_t leader_len = strlen(leader);
|
||||||
|
|
||||||
garray_T *ga = NULL;
|
garray_T *ga = NULL;
|
||||||
|
@@ -486,6 +486,43 @@ describe('cmdline', function()
|
|||||||
|
|
||||||
feed('<esc>')
|
feed('<esc>')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_search_wildmenu_iminsert()
|
||||||
|
it('search wildmenu pum with iminsert=1', function()
|
||||||
|
local screen = Screen.new(65, 20)
|
||||||
|
exec([[
|
||||||
|
set wop=pum imi=1
|
||||||
|
setlocal iskeyword=!-~,192-255
|
||||||
|
call setline(1, [
|
||||||
|
\ " global toggle global-local global/local glyphs toggles English",
|
||||||
|
\ "accordingly. toggled accordingly single-byte glob() glob(pat,",
|
||||||
|
\ "English, 'gli' global-ime single-repeat 'toggle' 'toggle'.",
|
||||||
|
\ ])
|
||||||
|
]])
|
||||||
|
feed('/gl<Tab>')
|
||||||
|
screen:expect([[
|
||||||
|
{12: global }lobal-local global/local glyphs toggles English |
|
||||||
|
{4: gle }gled accordingly single-byte glob() glob(pat, |
|
||||||
|
{4: global-local }lobal-ime single-repeat 'toggle' 'toggle'. |
|
||||||
|
{4: global/local }{1: }|
|
||||||
|
{4: glyphs }{1: }|
|
||||||
|
{4: gles }{1: }|
|
||||||
|
{4: glish }{1: }|
|
||||||
|
{4: gly. }{1: }|
|
||||||
|
{4: gled }{1: }|
|
||||||
|
{4: gly }{1: }|
|
||||||
|
{4: gle-byte }{1: }|
|
||||||
|
{4: glob() }{1: }|
|
||||||
|
{4: glob(pat, }{1: }|
|
||||||
|
{4: glish, }{1: }|
|
||||||
|
{4: gli' }{1: }|
|
||||||
|
{4: global-ime }{1: }|
|
||||||
|
{4: gle-repeat }{1: }|
|
||||||
|
{4: gle' }{1: }|
|
||||||
|
{4: gle'. }{1: }|
|
||||||
|
/global^ |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('cmdwin', function()
|
describe('cmdwin', function()
|
||||||
|
@@ -4592,11 +4592,19 @@ func Test_search_complete()
|
|||||||
call feedkeys("gg/r\\n.*\\n\<tab>\<f9>", 'tx')
|
call feedkeys("gg/r\\n.*\\n\<tab>\<f9>", 'tx')
|
||||||
call assert_equal(['r\nFoobar\nfooBAr', 'r\nfooBAr\nFooBARR'], g:compl_info.matches)
|
call assert_equal(['r\nFoobar\nfooBAr', 'r\nfooBAr\nFooBARR'], g:compl_info.matches)
|
||||||
|
|
||||||
|
" Issue #17858
|
||||||
|
%d
|
||||||
|
set wildcharm=0 incsearch& ignorecase& smartcase& wildoptions&
|
||||||
|
setlocal iskeyword=!-~,192-255
|
||||||
|
let l:lines = ['th=~/foo', 'these', 'tho']
|
||||||
|
call setline(1, l:lines)
|
||||||
|
call feedkeys("G/th\<tab>\<f9>", 'tx')
|
||||||
|
call assert_equal(l:lines, g:compl_info.matches)
|
||||||
|
|
||||||
bw!
|
bw!
|
||||||
call Ntest_override("char_avail", 0)
|
call Ntest_override("char_avail", 0)
|
||||||
delfunc GetComplInfo
|
delfunc GetComplInfo
|
||||||
unlet! g:compl_info
|
unlet! g:compl_info
|
||||||
set wildcharm=0 incsearch& ignorecase& smartcase& wildoptions&
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_wildmenu_screendump()
|
func Test_search_wildmenu_screendump()
|
||||||
@@ -4647,6 +4655,25 @@ func Test_search_wildmenu_screendump()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Issue #17858
|
||||||
|
func Test_search_wildmenu_iminsert()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
let lines =<< trim [SCRIPT]
|
||||||
|
set wop=pum imi=1
|
||||||
|
h wildoptions
|
||||||
|
[SCRIPT]
|
||||||
|
call writefile(lines, 'XTest_search_wildmenu', 'D')
|
||||||
|
let buf = RunVimInTerminal('-S XTest_search_wildmenu', {'rows': 20})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "/gl\<Tab>")
|
||||||
|
call TermWait(buf, 50)
|
||||||
|
call VerifyScreenDump(buf, 'Test_search_wildmenu_iminsert', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "\<esc>")
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test wildcharm completion for :s and :g with range
|
" Test wildcharm completion for :s and :g with range
|
||||||
func Test_range_complete()
|
func Test_range_complete()
|
||||||
set wildcharm=<c-z>
|
set wildcharm=<c-z>
|
||||||
|
Reference in New Issue
Block a user