0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 7.4.926

Problem:    Completing the longest match doesn't work properly with multi-byte
            characters.
Solution:   When using multi-byte characters use another way to find the
            longest match. (Hirohito Higashi)
This commit is contained in:
Bram Moolenaar
2015-11-19 19:00:05 +01:00
parent a0ed84a268
commit 4f8fa1633c
4 changed files with 47 additions and 5 deletions

View File

@@ -3691,20 +3691,37 @@ ExpandOne(xp, str, orig, options, mode)
/* Find longest common part */ /* Find longest common part */
if (mode == WILD_LONGEST && xp->xp_numfiles > 0) if (mode == WILD_LONGEST && xp->xp_numfiles > 0)
{ {
for (len = 0; xp->xp_files[0][len]; ++len) int mb_len = 1;
int c0, ci;
for (len = 0; xp->xp_files[0][len]; len += mb_len)
{ {
for (i = 0; i < xp->xp_numfiles; ++i) #ifdef FEAT_MBYTE
if (has_mbyte)
{ {
mb_len = (*mb_ptr2len)(&xp->xp_files[0][len]);
c0 =(* mb_ptr2char)(&xp->xp_files[0][len]);
}
else
#endif
c0 = xp->xp_files[i][len];
for (i = 1; i < xp->xp_numfiles; ++i)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
ci =(* mb_ptr2char)(&xp->xp_files[i][len]);
else
#endif
ci = xp->xp_files[i][len];
if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES
|| xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_FILES
|| xp->xp_context == EXPAND_SHELLCMD || xp->xp_context == EXPAND_SHELLCMD
|| xp->xp_context == EXPAND_BUFFERS)) || xp->xp_context == EXPAND_BUFFERS))
{ {
if (TOLOWER_LOC(xp->xp_files[i][len]) != if (MB_TOLOWER(c0) != MB_TOLOWER(ci))
TOLOWER_LOC(xp->xp_files[0][len]))
break; break;
} }
else if (xp->xp_files[i][len] != xp->xp_files[0][len]) else if (c0 != ci)
break; break;
} }
if (i < xp->xp_numfiles) if (i < xp->xp_numfiles)
@@ -3714,6 +3731,7 @@ ExpandOne(xp, str, orig, options, mode)
break; break;
} }
} }
ss = alloc((unsigned)len + 1); ss = alloc((unsigned)len + 1);
if (ss) if (ss)
vim_strncpy(ss, xp->xp_files[0], (size_t)len); vim_strncpy(ss, xp->xp_files[0], (size_t)len);

View File

@@ -17,6 +17,25 @@ STARTTEST
: $put=strchars(str, 0) : $put=strchars(str, 0)
: $put=strchars(str, 1) : $put=strchars(str, 1)
:endfor :endfor
:" Test for customlist completion
:function! CustomComplete1(lead, line, pos)
: return ['あ', 'い']
:endfunction
:command -nargs=1 -complete=customlist,CustomComplete1 Test1 :
:call feedkeys(":Test1 \<C-L>'\<C-B>$put='\<CR>", 't')
:
:function! CustomComplete2(lead, line, pos)
: return ['あたし', 'あたま', 'あたりめ']
:endfunction
:command -nargs=1 -complete=customlist,CustomComplete2 Test2 :
:call feedkeys(":Test2 \<C-L>'\<C-B>$put='\<CR>", 't')
:
:function! CustomComplete3(lead, line, pos)
: return ['Nこ', 'Nん', 'Nぶ']
:endfunction
:command -nargs=1 -complete=customlist,CustomComplete3 Test3 :
:call feedkeys(":Test3 \<C-L>'\<C-B>$put='\<CR>", 't')
:
:call garbagecollect(1) :call garbagecollect(1)
:/^start:/,$wq! test.out :/^start:/,$wq! test.out
ENDTEST ENDTEST

View File

@@ -17,3 +17,6 @@ bxbb
1 1
1 1
1 1
Test1
Test2 あた
Test3 N

View File

@@ -741,6 +741,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 */
/**/
926,
/**/ /**/
925, 925,
/**/ /**/