patch 9.1.1769: completion: "preinsert" insert wrong word with 'smartcase' and 'autocomplete'
Problem: completion: "preinsert" insert wrong word with 'smartcase' and
'autocomplete'
Solution: Add compare completed item with the leader (Girish Palya)
closes: #18313
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
57d243e27d
commit
a8f7957d0b
@ -5861,12 +5861,13 @@ find_common_prefix(size_t *prefix_len, int curbuf_only)
|
|||||||
if (!match_limit_exceeded && (!curbuf_only
|
if (!match_limit_exceeded && (!curbuf_only
|
||||||
|| cpt_sources_array[cur_source].cs_flag == '.'))
|
|| cpt_sources_array[cur_source].cs_flag == '.'))
|
||||||
{
|
{
|
||||||
if (first == NULL)
|
if (first == NULL && STRNCMP(ins_compl_leader(),
|
||||||
|
compl->cp_str.string, ins_compl_leader_len()) == 0)
|
||||||
{
|
{
|
||||||
first = compl->cp_str.string;
|
first = compl->cp_str.string;
|
||||||
len = (int)STRLEN(first);
|
len = (int)STRLEN(first);
|
||||||
}
|
}
|
||||||
else
|
else if (first != NULL)
|
||||||
{
|
{
|
||||||
int j = 0; // count in bytes
|
int j = 0; // count in bytes
|
||||||
char_u *s1 = first;
|
char_u *s1 = first;
|
||||||
@ -5894,7 +5895,7 @@ find_common_prefix(size_t *prefix_len, int curbuf_only)
|
|||||||
|
|
||||||
vim_free(match_count);
|
vim_free(match_count);
|
||||||
|
|
||||||
if (len > get_compl_len())
|
if (len > (int)ins_compl_leader_len())
|
||||||
{
|
{
|
||||||
*prefix_len = (size_t)len;
|
*prefix_len = (size_t)len;
|
||||||
return first;
|
return first;
|
||||||
|
|||||||
@ -5651,7 +5651,18 @@ func Test_autocomplete_completeopt_preinsert()
|
|||||||
call DoTest("f", 'f', 2)
|
call DoTest("f", 'f', 2)
|
||||||
set cot-=fuzzy
|
set cot-=fuzzy
|
||||||
|
|
||||||
|
" leader should match prefix of inserted word
|
||||||
|
%delete
|
||||||
|
set smartcase ignorecase
|
||||||
|
call setline(1, ["FOO"])
|
||||||
|
call feedkeys($"Gof\<F5>\<Esc>", 'tx')
|
||||||
|
call assert_equal('f', g:line)
|
||||||
|
call feedkeys($"SF\<F5>\<Esc>", 'tx')
|
||||||
|
call assert_equal('FOO', g:line)
|
||||||
|
set smartcase& ignorecase&
|
||||||
|
|
||||||
" Verify that redo (dot) works
|
" Verify that redo (dot) works
|
||||||
|
%delete
|
||||||
call setline(1, ["foobar", "foozbar", "foobaz", "changed", "change"])
|
call setline(1, ["foobar", "foozbar", "foobaz", "changed", "change"])
|
||||||
call feedkeys($"/foo\<CR>", 'tx')
|
call feedkeys($"/foo\<CR>", 'tx')
|
||||||
call feedkeys($"cwch\<C-N>\<Esc>n.n.", 'tx')
|
call feedkeys($"cwch\<C-N>\<Esc>n.n.", 'tx')
|
||||||
|
|||||||
@ -724,6 +724,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 */
|
||||||
|
/**/
|
||||||
|
1769,
|
||||||
/**/
|
/**/
|
||||||
1768,
|
1768,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user