patch 9.1.1594: completion: search completion throws errors
Problem: completion: search completion throws errors, wrong placement
of pum menu with 'imi'=1 (berggeist)
Solution: Fix those errors (Girish Palya)
fixes: #17858
closes: #17870
Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
bb0860abc9
commit
66467cf5d8
@ -4789,17 +4789,29 @@ copy_substring_from_pos(pos_T *start, pos_T *end, char_u **match,
|
|||||||
static int
|
static int
|
||||||
is_regex_match(char_u *pat, char_u *str)
|
is_regex_match(char_u *pat, char_u *str)
|
||||||
{
|
{
|
||||||
|
if (STRCMP(pat, str) == 0)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
regmatch_T regmatch;
|
regmatch_T regmatch;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
++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;
|
||||||
regmatch.rm_ic = p_ic;
|
regmatch.rm_ic = p_ic;
|
||||||
if (p_ic && p_scs)
|
if (p_ic && p_scs)
|
||||||
regmatch.rm_ic = !pat_has_uppercase(pat);
|
regmatch.rm_ic = !pat_has_uppercase(pat);
|
||||||
|
|
||||||
|
++emsg_off;
|
||||||
|
++msg_silent;
|
||||||
result = vim_regexec_nl(®match, str, (colnr_T)0);
|
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;
|
||||||
|
|||||||
@ -109,7 +109,7 @@ pum_display(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_RIGHTLEFT
|
#ifdef FEAT_RIGHTLEFT
|
||||||
pum_rl = State != MODE_CMDLINE && curwin->w_p_rl;
|
pum_rl = (State & MODE_CMDLINE) == 0 && curwin->w_p_rl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -129,7 +129,7 @@ pum_display(
|
|||||||
// Remember the essential parts of the window position and size, so we
|
// Remember the essential parts of the window position and size, so we
|
||||||
// can decide when to reposition the popup menu.
|
// can decide when to reposition the popup menu.
|
||||||
pum_window = curwin;
|
pum_window = curwin;
|
||||||
if (State == MODE_CMDLINE)
|
if (State & MODE_CMDLINE)
|
||||||
// cmdline completion popup menu
|
// cmdline completion popup menu
|
||||||
pum_win_row = cmdline_row;
|
pum_win_row = cmdline_row;
|
||||||
else
|
else
|
||||||
@ -165,7 +165,7 @@ pum_display(
|
|||||||
&& pum_win_row - above_row > (below_row - above_row) / 2)
|
&& pum_win_row - above_row > (below_row - above_row) / 2)
|
||||||
{
|
{
|
||||||
// pum above "pum_win_row"
|
// pum above "pum_win_row"
|
||||||
if (State == MODE_CMDLINE)
|
if (State & MODE_CMDLINE)
|
||||||
// for cmdline pum, no need for context lines
|
// for cmdline pum, no need for context lines
|
||||||
context_lines = 0;
|
context_lines = 0;
|
||||||
else
|
else
|
||||||
@ -191,7 +191,7 @@ pum_display(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// pum below "pum_win_row"
|
// pum below "pum_win_row"
|
||||||
if (State == MODE_CMDLINE)
|
if (State & MODE_CMDLINE)
|
||||||
// for cmdline pum, no need for context lines
|
// for cmdline pum, no need for context lines
|
||||||
context_lines = 0;
|
context_lines = 0;
|
||||||
else
|
else
|
||||||
@ -230,7 +230,7 @@ pum_display(
|
|||||||
max_width = p_pmw;
|
max_width = p_pmw;
|
||||||
|
|
||||||
// Calculate column
|
// Calculate column
|
||||||
if (State == MODE_CMDLINE)
|
if (State & MODE_CMDLINE)
|
||||||
// cmdline completion popup menu
|
// cmdline completion popup menu
|
||||||
cursor_col = cmdline_compl_startcol();
|
cursor_col = cmdline_compl_startcol();
|
||||||
else
|
else
|
||||||
@ -440,7 +440,7 @@ pum_compute_text_attrs(char_u *text, hlf_T hlf, int user_hlattr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
is_select = hlf == HLF_PSI;
|
is_select = hlf == HLF_PSI;
|
||||||
leader = State == MODE_CMDLINE ? cmdline_compl_pattern()
|
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;
|
||||||
@ -449,7 +449,7 @@ pum_compute_text_attrs(char_u *text, hlf_T hlf, int user_hlattr)
|
|||||||
if (attrs == NULL)
|
if (attrs == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
in_fuzzy = State == MODE_CMDLINE ? cmdline_compl_is_fuzzy()
|
in_fuzzy = (State & MODE_CMDLINE) ? cmdline_compl_is_fuzzy()
|
||||||
: (get_cot_flags() & COT_FUZZY) != 0;
|
: (get_cot_flags() & COT_FUZZY) != 0;
|
||||||
leader_len = STRLEN(leader);
|
leader_len = STRLEN(leader);
|
||||||
|
|
||||||
|
|||||||
20
src/testdir/dumps/Test_search_wildmenu_iminsert.dump
Normal file
20
src/testdir/dumps/Test_search_wildmenu_iminsert.dump
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
| +0#0000001#e0e0e08|g|l|o|b|a|l| @8| +0#0000000#0000001|e+0&#ffffff0|s@1|:| |c|y|c|l|e| |f|u|l@1| |m|a|t|c|h|e|s| @34
|
||||||
|
| +0#0000001#ffd7ff255|g|l|e| @11| +0#0000000#0000001|s+0#0000e05#ffffff0|e|t| |w|i|l|d|m|o|d|e|=|n|o|s|e|l|e|c|t|:|l|a|s|t|u|s|e|d|,|f|u|l@1| +0#0000000&@22
|
||||||
|
| +0#0000001#ffd7ff255|g|l|o|b|a|l|-|l|o|c|a|l| @2| +0#0000000#0000001|b+0&#ffffff0|o|v|e|,| |b|u|t| |b|u|f@1|e|r| |m|a|t|c|h|e|s| |a|r|e| |s|o|r|t|e|d| |b|y| |t|i|m|e| |l|a|s|t| |u|s|e|d| @4
|
||||||
|
| +0#0000001#ffd7ff255|g|l|o|b|a|l|/|l|o|c|a|l| @2| +0#0000000#0000001| +0&#ffffff0|h|e|r|e|:| |c+0#00e0e07&|m|d|l|i|n|e|-|c|o|m|p|l|e|t|i|o|n|.+0#0000000&| @31
|
||||||
|
| +0#0000001#ffd7ff255|g|l|y|p|h|s| @8| +0#0000000#0000001| +0&#ffffff0@57
|
||||||
|
| +0#0000001#ffd7ff255|g|l|e|s| @10| +0#0000000#0000001| +0&#ffffff0@30|'+0#e000002&|w|i|l|d|o|p|t|i|o|n|s|'| +0#0000000&|'+0#e000002&|w|o|p|'| +0#0000000&@7
|
||||||
|
| +0#0000001#ffd7ff255|g|l|i|s|h| @9| +0#0000000#0000001|p+0#00e0003#ffffff0|'| +0#0000000&@4|s|t|r|i|n|g| @1|(|d|e|f|a|u|l|t| |"@1|)| @30
|
||||||
|
| +0#0000001#ffd7ff255|g|l|y|.| @10| +0#0000000#0000001| +0&#ffffff0@6|g|l|o|b|a|l| @44
|
||||||
|
| +0#0000001#ffd7ff255|g|l|e|d| @10| +0#0000000#0000001| +0&#ffffff0|w|o|r|d|s| |t|h|a|t| |c|h|a|n|g|e| |h|o|w| |c+0#00e0e07&|m|d|l|i|n|e|-|c|o|m|p|l|e|t|i|o|n| +0#0000000&|i|s| |d|o|n|e|.| @7
|
||||||
|
| +0#0000001#ffd7ff255|g|l|y| @11| +0#0000000#0000001| +0&#ffffff0@57
|
||||||
|
| +0#0000001#ffd7ff255|g|l|e|-|b|y|t|e| @6| +0#0000000#0000001|w+0&#ffffff0|i|n|g| |v|a|l|u|e|s| |a|r|e| |s|u|p@1|o|r|t|e|d|:| @31
|
||||||
|
| +0#0000001#ffd7ff255|g|l|o|b|(|)| @8| +0#0000000#0000001|x+0&#ffffff0|t| @4|W|h|e|n| |t|h|i|s| |f|l|a|g| |i|s| |p|r|e|s|e|n|t|,| |s|e|a|r|c|h| |p|a|t@1|e|r|n| |c|o|m|p|l|e|t|i|o
|
||||||
|
| +0#0000001#ffd7ff255|g|l|o|b|(|p|a|t|,| @5| +0#0000000#a8a8a8255| +0&#ffffff0@57
|
||||||
|
| +0#0000001#ffd7ff255|g|l|i|s|h|,| @8| +0#0000000#a8a8a8255| +0&#ffffff0@6|(|e|.|g|.|,| |i|n| |/+0#00e0e07&|,+0#0000000&| |?+0#00e0e07&|,+0#0000000&| |:+0#00e0e07&|s|,+0#0000000&| |:+0#00e0e07&|g|,+0#0000000&| |:+0#00e0e07&|v|,+0#0000000&| |a|n|d| |:+0#00e0e07&|v|i|m|)+0#0000000&| @13
|
||||||
|
| +0#0000001#ffd7ff255|g|l|i|'| @10| +0#0000000#a8a8a8255| +0&#ffffff0@6|s|h|o|w|s| |e|x|a|c|t| |b|u|f@1|e|r| |t|e|x|t| |a|s| |m|e|n|u| |i|t|e|m|s|,| |w|i|t|h|o|u|t| @4
|
||||||
|
| +0#0000001#ffd7ff255|g|l|o|b|a|l|-|i|m|e| @4| +0#0000000#a8a8a8255| +0&#ffffff0@6|p|r|e|s|e|r|v|i|n|g| |r|e|g|e|x| |a|r|t|i|f|a|c|t|s| |l|i|k|e| |p|o|s|i|t|i|o|n| @10
|
||||||
|
| +0#0000001#ffd7ff255|g|l|e|-|r|e|p|e|a|t| @4| +0#0000000#a8a8a8255|]+3&#ffffff0|[|R|O|]| @27|<|l|a|n|g|>| |9@1|7|2|,|7|-|4|9| @5|9|7|%
|
||||||
|
| +0#0000001#ffd7ff255|g|l|e|'| @10| +0#0000000#a8a8a8255| +0&#ffffff0@57
|
||||||
|
| +0#0000001#ffd7ff255|g|l|e|'|.| @9| +0#0000000#a8a8a8255| +1&#ffffff0@32|<|l|a|n|g|>| |0|,|0|-|1| @9|A|l@1
|
||||||
|
|/+0&&|g|l|o|b|a|l> @67
|
||||||
@ -4564,11 +4564,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 test_override("char_avail", 0)
|
call test_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()
|
||||||
@ -4619,6 +4627,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>
|
||||||
|
|||||||
@ -719,6 +719,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1594,
|
||||||
/**/
|
/**/
|
||||||
1593,
|
1593,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user