summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-11-19 19:00:05 +0100
committerBram Moolenaar <Bram@vim.org>2015-11-19 19:00:05 +0100
commit4f8fa1633cdfbd09a41160c8480fe67c198067e9 (patch)
tree8dba743f40ae9754db879315d24fd4737a347b31 /src
parenta0ed84a26897c994512873a895b9fc54e90c6845 (diff)
downloadvim-git-4f8fa1633cdfbd09a41160c8480fe67c198067e9.tar.gz
patch 7.4.926v7.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)
Diffstat (limited to 'src')
-rw-r--r--src/ex_getln.c28
-rw-r--r--src/testdir/test_utf8.in19
-rw-r--r--src/testdir/test_utf8.ok3
-rw-r--r--src/version.c2
4 files changed, 47 insertions, 5 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 5d7ea2009..33d612bfa 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -3691,20 +3691,37 @@ ExpandOne(xp, str, orig, options, mode)
/* Find longest common part */
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
|| xp->xp_context == EXPAND_FILES
|| xp->xp_context == EXPAND_SHELLCMD
|| xp->xp_context == EXPAND_BUFFERS))
{
- if (TOLOWER_LOC(xp->xp_files[i][len]) !=
- TOLOWER_LOC(xp->xp_files[0][len]))
+ if (MB_TOLOWER(c0) != MB_TOLOWER(ci))
break;
}
- else if (xp->xp_files[i][len] != xp->xp_files[0][len])
+ else if (c0 != ci)
break;
}
if (i < xp->xp_numfiles)
@@ -3714,6 +3731,7 @@ ExpandOne(xp, str, orig, options, mode)
break;
}
}
+
ss = alloc((unsigned)len + 1);
if (ss)
vim_strncpy(ss, xp->xp_files[0], (size_t)len);
diff --git a/src/testdir/test_utf8.in b/src/testdir/test_utf8.in
index 8bc783e29..1156342e3 100644
--- a/src/testdir/test_utf8.in
+++ b/src/testdir/test_utf8.in
@@ -17,6 +17,25 @@ STARTTEST
: $put=strchars(str, 0)
: $put=strchars(str, 1)
: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)
:/^start:/,$wq! test.out
ENDTEST
diff --git a/src/testdir/test_utf8.ok b/src/testdir/test_utf8.ok
index 8ccdd6d7a..c6559226a 100644
--- a/src/testdir/test_utf8.ok
+++ b/src/testdir/test_utf8.ok
@@ -17,3 +17,6 @@ bxbb
1
1
1
+Test1
+Test2 あた
+Test3 N
diff --git a/src/version.c b/src/version.c
index 5633841ed..20e0e9fe2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 926,
+/**/
925,
/**/
924,