From 36803323253e336e0d4a6efaa61c8b647ef78eba Mon Sep 17 00:00:00 2001 From: watiko Date: Mon, 15 Feb 2016 23:43:27 +0900 Subject: 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 --- src/nvim/ex_getln.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/nvim/ex_getln.c') 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 -- cgit From 9036f1644fe638af6943cff7fa19ee011ba81e8d Mon Sep 17 00:00:00 2001 From: watiko Date: Tue, 16 Feb 2016 22:53:32 +0900 Subject: vim-patch:7.4.933 Problem: Crash when using longest completion match. Solution: Fix array index. https://github.com/vim/vim/commit/e4eda3bc7157932b0bf380fd3fdc1ba8f4438b60 --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 003d3c9ef0..39bff9b2ad 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2969,7 +2969,7 @@ ExpandOne ( mb_len = (* mb_ptr2len)(&xp->xp_files[0][len]); c0 = (* mb_ptr2char)(&xp->xp_files[0][len]); } else { - c0 = xp->xp_files[i][len]; + c0 = xp->xp_files[0][len]; } for (i = 1; i < xp->xp_numfiles; ++i) { if (has_mbyte) { -- cgit