From 36803323253e336e0d4a6efaa61c8b647ef78eba Mon Sep 17 00:00:00 2001 From: watiko Date: Mon, 15 Feb 2016 23:43:27 +0900 Subject: [PATCH 1/4] 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 ++++++++++++++++++++++------ src/nvim/version.c | 2 +- test/functional/legacy/utf8_spec.lua | 32 +++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 9 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 diff --git a/test/functional/legacy/utf8_spec.lua b/test/functional/legacy/utf8_spec.lua index c16b1c45f4..d2315b3590 100644 --- a/test/functional/legacy/utf8_spec.lua +++ b/test/functional/legacy/utf8_spec.lua @@ -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 '$put='") + + source([[ + function! CustomComplete2(lead, line, pos) + return ['あたし', 'あたま', 'あたりめ'] + endfunction + command -nargs=1 -complete=customlist,CustomComplete2 Test2 :]]) + feed(":Test2 '$put='") + + source([[ + function! CustomComplete3(lead, line, pos) + return ['Nこ', 'Nん', 'Nぶ'] + endfunction + command -nargs=1 -complete=customlist,CustomComplete3 Test3 :]]) + feed(":Test3 '$put='") + + expect([[ + + Test1 + Test2 あた + Test3 N]]) + end) end) From 4f3ea0379eb015fc7b4f93c15e3baadf1c17e7bd Mon Sep 17 00:00:00 2001 From: watiko Date: Tue, 16 Feb 2016 00:17:07 +0900 Subject: [PATCH 2/4] vim-patch:7.4.932 Problem: test_utf8 has confusing dummy command. Solution: Use a real command instead of a colon. https://github.com/vim/vim/commit/8f08dab18df6dbf6c4b4973fd2d480e4bffb82d8 --- src/nvim/version.c | 2 +- test/functional/legacy/utf8_spec.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nvim/version.c b/src/nvim/version.c index 8268465743..fd84f566fd 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -356,7 +356,7 @@ static int included_patches[] = { // 935, // 934 NA // 933, - // 932, + 932, // 931 NA // 930 NA 929, diff --git a/test/functional/legacy/utf8_spec.lua b/test/functional/legacy/utf8_spec.lua index d2315b3590..d33ba6b5fd 100644 --- a/test/functional/legacy/utf8_spec.lua +++ b/test/functional/legacy/utf8_spec.lua @@ -57,21 +57,21 @@ describe('utf8', function() function! CustomComplete1(lead, line, pos) return ['あ', 'い'] endfunction - command -nargs=1 -complete=customlist,CustomComplete1 Test1 :]]) + command -nargs=1 -complete=customlist,CustomComplete1 Test1 echo]]) feed(":Test1 '$put='") source([[ function! CustomComplete2(lead, line, pos) return ['あたし', 'あたま', 'あたりめ'] endfunction - command -nargs=1 -complete=customlist,CustomComplete2 Test2 :]]) + command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo]]) feed(":Test2 '$put='") source([[ function! CustomComplete3(lead, line, pos) return ['Nこ', 'Nん', 'Nぶ'] endfunction - command -nargs=1 -complete=customlist,CustomComplete3 Test3 :]]) + command -nargs=1 -complete=customlist,CustomComplete3 Test3 echo]]) feed(":Test3 '$put='") expect([[ From 9036f1644fe638af6943cff7fa19ee011ba81e8d Mon Sep 17 00:00:00 2001 From: watiko Date: Tue, 16 Feb 2016 22:53:32 +0900 Subject: [PATCH 3/4] 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 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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) { diff --git a/src/nvim/version.c b/src/nvim/version.c index fd84f566fd..5fea4d60ba 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -355,7 +355,7 @@ static int included_patches[] = { // 936, // 935, // 934 NA - // 933, + 933, 932, // 931 NA // 930 NA From c9f4f828d5d28ad2405b47ecff7994f13b8a562b Mon Sep 17 00:00:00 2001 From: watiko Date: Tue, 16 Feb 2016 22:56:35 +0900 Subject: [PATCH 4/4] version.c: Mark 7.4.935 NA Problem: test_utf8 fails on MS-Windows when executed with gvim. Solution: Use the insert flag on feedkeys() to put the string before the ":" that was already read when checking for available chars. https://github.com/vim/vim/commit/6040256d8b0404564ac6f192296b12ea9d175e7d --- feedkeys() is not used by legacy test utf8. --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/version.c b/src/nvim/version.c index 5fea4d60ba..a1db346d1f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -353,7 +353,7 @@ static int included_patches[] = { // 938 NA // 937, // 936, - // 935, + // 935 NA // 934 NA 933, 932,