Hi Bram and List!
How to reproduce:
- Prepare vimrc for reproduce.
$ cat xxx.vim
function! CustomComplete(lead, line, pos)
return ['あたし', 'あたま', 'あたりめ']
endfunction
command -nargs=1 -complete=customlist,CustomComplete Test :
- Run pure vim with above resource file.
$ vim -N -u xxx.vim
- Do custom-list completion using longest match in command-line.
:Test <C-L>
Expected behavior:
- あた Completed.
:Test あた
Actual behavior:
- あた<e3> Completed.
:Test あた<e3>
I wrote a patch with test.
Please check it.
BTW, inside for-loop started 0 is waste. 1 is correct.
--
Best regards,
Hirohito Higashi (a.k.a h_east)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ex_getln.c b/src/ex_getln.c
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -3691,9 +3691,43 @@
/* Find longest common part */
if (mode == WILD_LONGEST && xp->xp_numfiles > 0)
{
+#ifdef FEAT_MBYTE
+ if (has_mbyte)
+ {
+ int mb_len = 0;
+
+ for (len = 0; xp->xp_files[0][len]; len+=mb_len)
+ {
+ mb_len = (*mb_ptr2len)(&xp->xp_files[0][len]);
+ for (i = 1; i < xp->xp_numfiles; ++i)
+ {
+ if (mb_len == 1 && 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]))
+ break;
+ }
+ else if (vim_memcmp(&xp->xp_files[i][len],
+ &xp->xp_files[0][len], mb_len))
+ break;
+ }
+ if (i < xp->xp_numfiles)
+ {
+ if (!(options & WILD_NO_BEEP))
+ vim_beep(BO_WILD);
+ break;
+ }
+ }
+ }
+ else
+#endif
for (len = 0; xp->xp_files[0][len]; ++len)
{
- for (i = 0; i < xp->xp_numfiles; ++i)
+ for (i = 1; i < xp->xp_numfiles; ++i)
{
if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES
|| xp->xp_context == EXPAND_FILES
diff --git a/src/testdir/test_utf8.in b/src/testdir/test_utf8.in
--- a/src/testdir/test_utf8.in
+++ b/src/testdir/test_utf8.in
@@ -17,6 +17,25 @@
: $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
--- a/src/testdir/test_utf8.ok
+++ b/src/testdir/test_utf8.ok
@@ -17,3 +17,6 @@
1
1
1
+Test1
+Test2 あた
+Test3 N