mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-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)
4f8fa1633c
This commit is contained in:
parent
7609a96a35
commit
3680332325
@ -2957,20 +2957,37 @@ ExpandOne (
|
||||
}
|
||||
}
|
||||
|
||||
/* Find longest common part */
|
||||
// Find longest common part
|
||||
if (mode == WILD_LONGEST && xp->xp_numfiles > 0) {
|
||||
size_t len;
|
||||
for (len = 0; xp->xp_files[0][len]; ++len) {
|
||||
for (i = 0; i < xp->xp_numfiles; ++i) {
|
||||
size_t mb_len = 1;
|
||||
int c0;
|
||||
int ci;
|
||||
|
||||
for (len = 0; xp->xp_files[0][len]; len += mb_len) {
|
||||
if (has_mbyte) {
|
||||
mb_len = (* mb_ptr2len)(&xp->xp_files[0][len]);
|
||||
c0 = (* mb_ptr2char)(&xp->xp_files[0][len]);
|
||||
} else {
|
||||
c0 = xp->xp_files[i][len];
|
||||
}
|
||||
for (i = 1; i < xp->xp_numfiles; ++i) {
|
||||
if (has_mbyte) {
|
||||
ci =(* mb_ptr2char)(&xp->xp_files[i][len]);
|
||||
} else {
|
||||
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 (vim_tolower(c0) != vim_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) {
|
||||
if (!(options & WILD_NO_BEEP)) {
|
||||
@ -2979,8 +2996,9 @@ ExpandOne (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ss = (char_u *)xstrndup((char *)xp->xp_files[0], len);
|
||||
findex = -1; /* next p_wc gets first one */
|
||||
findex = -1; // next p_wc gets first one
|
||||
}
|
||||
|
||||
// Concatenate all matching names
|
||||
|
@ -362,7 +362,7 @@ static int included_patches[] = {
|
||||
929,
|
||||
// 928 NA
|
||||
// 927 NA
|
||||
// 926,
|
||||
926,
|
||||
// 925,
|
||||
// 924 NA
|
||||
// 923 NA
|
||||
|
@ -4,9 +4,10 @@ local helpers = require('test.functional.helpers')
|
||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
||||
local execute, expect = helpers.execute, helpers.expect
|
||||
local eq, eval = helpers.eq, helpers.eval
|
||||
local source = helpers.source
|
||||
|
||||
describe('utf8', function()
|
||||
setup(clear)
|
||||
before_each(clear)
|
||||
|
||||
it('is working', function()
|
||||
insert('start:')
|
||||
@ -50,4 +51,33 @@ describe('utf8', function()
|
||||
eq(1, eval('strchars("\\u20dd", 0)'))
|
||||
eq(1, eval('strchars("\\u20dd", 1)'))
|
||||
end)
|
||||
|
||||
it('customlist completion', function()
|
||||
source([[
|
||||
function! CustomComplete1(lead, line, pos)
|
||||
return ['あ', 'い']
|
||||
endfunction
|
||||
command -nargs=1 -complete=customlist,CustomComplete1 Test1 :]])
|
||||
feed(":Test1 <C-L>'<C-B>$put='<CR>")
|
||||
|
||||
source([[
|
||||
function! CustomComplete2(lead, line, pos)
|
||||
return ['あたし', 'あたま', 'あたりめ']
|
||||
endfunction
|
||||
command -nargs=1 -complete=customlist,CustomComplete2 Test2 :]])
|
||||
feed(":Test2 <C-L>'<C-B>$put='<CR>")
|
||||
|
||||
source([[
|
||||
function! CustomComplete3(lead, line, pos)
|
||||
return ['Nこ', 'Nん', 'Nぶ']
|
||||
endfunction
|
||||
command -nargs=1 -complete=customlist,CustomComplete3 Test3 :]])
|
||||
feed(":Test3 <C-L>'<C-B>$put='<CR>")
|
||||
|
||||
expect([[
|
||||
|
||||
Test1
|
||||
Test2 あた
|
||||
Test3 N]])
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user