diff options
author | watiko <service@mail.watiko.net> | 2016-02-15 23:43:27 +0900 |
---|---|---|
committer | watiko <service@mail.watiko.net> | 2016-02-16 00:15:52 +0900 |
commit | 36803323253e336e0d4a6efaa61c8b647ef78eba (patch) | |
tree | 3edc1f8364908c19a19282dc135333e25d2edac8 /src | |
parent | 7609a96a35224be3d7f3ba77691f9115e0281b4e (diff) | |
download | rneovim-36803323253e336e0d4a6efaa61c8b647ef78eba.tar.gz rneovim-36803323253e336e0d4a6efaa61c8b647ef78eba.tar.bz2 rneovim-36803323253e336e0d4a6efaa61c8b647ef78eba.zip |
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)
https://github.com/vim/vim/commit/4f8fa1633cdfbd09a41160c8480fe67c198067e9
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_getln.c | 32 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
2 files changed, 26 insertions, 8 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index d015f6b4a0..003d3c9ef0 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -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 diff --git a/src/nvim/version.c b/src/nvim/version.c index 4de63ebb10..8268465743 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -362,7 +362,7 @@ static int included_patches[] = { 929, // 928 NA // 927 NA - // 926, + 926, // 925, // 924 NA // 923 NA |