From ef748af01d4f34766b95e7470fb0c6bf23bf17ad Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 24 Aug 2022 13:33:15 +0800 Subject: vim-patch:8.2.3937: Insert mode completion function is too long Problem: Insert mode completion function is too long. Solution: Refactor into multiple functions. (Yegappan Lakshmanan, closes vim/vim#9423) https://github.com/vim/vim/commit/edc6f103907a004b9e2265e232dc8be8bc594601 Cherry-pick a typo fix from patch 8.2.3637. --- src/nvim/testdir/test_ins_complete.vim | 48 ++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 179218e48a..4cdede9cd0 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -44,11 +44,11 @@ func Test_ins_complete() exe "normal o\\\\\\\\\" call assert_equal('run1 run2', getline('.')) - set cpt=.,w,i + set cpt=.,\ ,w,i " i-add-expands and switches to local exe "normal OM\\\\\\\\\" call assert_equal("Makefile\tto\trun3", getline('.')) - " add-expands lines (it would end in an empty line if it didn't ignored + " add-expands lines (it would end in an empty line if it didn't ignore " itself) exe "normal o\\\\\\" call assert_equal("Makefile\tto\trun3", getline('.')) @@ -721,6 +721,17 @@ func Test_complete_across_line() close! endfunc +" Test for completing words with a '.' at the end of a word. +func Test_complete_joinspaces() + new + call setline(1, ['one two.', 'three. four']) + set joinspaces + exe "normal Goon\\\\\\\\\" + call assert_equal("one two. three. four", getline(3)) + set joinspaces& + bw! +endfunc + " Test for using CTRL-L to add one character when completing matching func Test_complete_add_onechar() new @@ -741,6 +752,39 @@ func Test_complete_add_onechar() close! endfunc +" Test for using CTRL-X CTRL-L to complete whole lines lines +func Test_complete_wholeline() + new + " complete one-line + call setline(1, ['a1', 'a2']) + exe "normal ggoa\\" + call assert_equal(['a1', 'a1', 'a2'], getline(1, '$')) + " go to the next match (wrapping around the buffer) + exe "normal 2GCa\\\" + call assert_equal(['a1', 'a', 'a2'], getline(1, '$')) + " go to the next match + exe "normal 2GCa\\\\" + call assert_equal(['a1', 'a2', 'a2'], getline(1, '$')) + exe "normal 2GCa\\\\\" + call assert_equal(['a1', 'a1', 'a2'], getline(1, '$')) + " repeat the test using CTRL-L + " go to the next match (wrapping around the buffer) + exe "normal 2GCa\\\" + call assert_equal(['a1', 'a2', 'a2'], getline(1, '$')) + " go to the next match + exe "normal 2GCa\\\\" + call assert_equal(['a1', 'a', 'a2'], getline(1, '$')) + exe "normal 2GCa\\\\\" + call assert_equal(['a1', 'a1', 'a2'], getline(1, '$')) + %d + " use CTRL-X CTRL-L to add one more line + call setline(1, ['a1', 'b1']) + setlocal complete=. + exe "normal ggOa\\\\\\" + call assert_equal(['a1', 'b1', '', 'a1', 'b1'], getline(1, '$')) + bw! +endfunc + " Test insert completion with 'cindent' (adjust the indent) func Test_complete_with_cindent() new -- cgit From 9ac44c7f5daf28cd155942dbc697b51c6b3afdc0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 24 Aug 2022 13:15:38 +0800 Subject: vim-patch:8.2.3944: insert mode completion functions are too long Problem: Insert mode completion functions are too long. Solution: Split up into multiple functions. (Yegappan Lakshmanan, closes vim/vim#9431) https://github.com/vim/vim/commit/5d2e007ccbfbd749a1f201d06965b8811ff50e6e Cherry-pick can_cindent_get() -> get_can_cindent() from patch 8.1.2062. --- src/nvim/testdir/test_ins_complete.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 4cdede9cd0..6f5f72e1ed 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -873,6 +873,25 @@ func Test_complete_stop() close! endfunc +" Test for typing CTRL-R in insert completion mode to insert a register +" content. +func Test_complete_reginsert() + new + call setline(1, ['a1', 'a12', 'a123', 'a1234']) + + " if a valid CTRL-X mode key is returned from =, then it should be + " processed. Otherwise, CTRL-X mode should be stopped and the key should be + " inserted. + exe "normal Goa\\=\"\\\"\" + call assert_equal('a123', getline(5)) + let @r = "\\" + exe "normal GCa\\r" + call assert_equal('a12', getline(5)) + exe "normal GCa\\=\"x\"\" + call assert_equal('a1234x', getline(5)) + bw! +endfunc + func Test_issue_7021() CheckMSWindows -- cgit From b0569f5813a019d5fe7a921b9d01f26eb1854b8d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 24 Aug 2022 16:59:03 +0800 Subject: vim-patch:9.0.0020: with some completion reading past end of string (#19922) Problem: With some completion reading past end of string. Solution: Check the length of the string. https://github.com/vim/vim/commit/f12129f1714f7d2301935bb21d896609bdac221c --- src/nvim/testdir/test_ins_complete.vim | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 6f5f72e1ed..54d3844100 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -947,4 +947,12 @@ func Test_complete_smartindent() delfunction! FooBarComplete endfunc +func Test_complete_overrun() + " this was going past the end of the copied text + new + sil norm si”0s0  + bwipe! +endfunc + + " vim: shiftwidth=2 sts=2 expandtab -- cgit From c366a63e4cdd97fc2818be348186a18e1b6eb8df Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 24 Aug 2022 21:08:17 +0800 Subject: vim-patch:9.0.0045: reading past end of completion with a long line Problem: Reading past end of completion with a long line and 'infercase' set. Solution: Allocate the string if needed. https://github.com/vim/vim/commit/caea66442d86e7bbba3bf3dc202c3c0d549b9853 Cherry-pick the deletion of a blank line from patch 9.0.0027. N/A patches for version.c: vim-patch:9.0.0054: compiler warning for size_t to int conversion Problem: Compiler warning for size_t to int conversion. Solution: Add type cast. (Mike Williams, closes vim/vim#10741) https://github.com/vim/vim/commit/c7bd2f08e531f08723cdc677212a3633d11c9a97 --- src/nvim/testdir/test_ins_complete.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 54d3844100..6c59041451 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -954,5 +954,20 @@ func Test_complete_overrun() bwipe! endfunc +func Test_infercase_very_long_line() + " this was truncating the line when inferring case + new + let longLine = "blah "->repeat(300) + let verylongLine = "blah "->repeat(400) + call setline(1, verylongLine) + call setline(2, longLine) + set ic infercase + exe "normal 2Go\\\" + call assert_equal(longLine, getline(3)) + + bwipe! + set noic noinfercase +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 5d1f0c3eca9675bfdeb75402ec3340d05cc34732 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 24 Aug 2022 21:40:14 +0800 Subject: vim-patch:9.0.0046: reading past end of completion with duplicate match Problem: Reading past end of completion with duplicate match. Solution: Check string length https://github.com/vim/vim/commit/baefde14550231f6468ac2ed2ed495bc381c0c92 --- src/nvim/testdir/test_ins_complete.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 6c59041451..cd7d83c8ea 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -969,5 +969,15 @@ func Test_infercase_very_long_line() set noic noinfercase endfunc +func Test_ins_complete_add() + " this was reading past the end of allocated memory + new + norm o + norm 7o€€ + sil! norm o + + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 6680002169a8cc505186e81acc161bec40658d73 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 24 Aug 2022 21:44:37 +0800 Subject: vim-patch:9.0.0060: accessing uninitialized memory when completing long line Problem: Accessing uninitialized memory when completing long line. Solution: Terminate string with NUL. https://github.com/vim/vim/commit/b9e717367c395490149495cf375911b5d9de889e --- src/nvim/testdir/test_ins_complete.vim | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index cd7d83c8ea..9aa3881724 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -965,6 +965,13 @@ func Test_infercase_very_long_line() exe "normal 2Go\\\" call assert_equal(longLine, getline(3)) + " check that the too long text is NUL terminated + %del + norm o + norm 1987ax + exec "norm ox\\" + call assert_equal(repeat('x', 1987), getline(3)) + bwipe! set noic noinfercase endfunc -- cgit From dd77a0062108d6ecfc00bbc50b0d6d738df0b89d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 24 Aug 2022 21:46:06 +0800 Subject: vim-patch:9.0.0102: reading past end of line with insert mode completion Problem: Reading past end of line with insert mode completion. Solution: Check text length. https://github.com/vim/vim/commit/a6f9e300161f4cb54713da22f65b261595e8e614 --- src/nvim/testdir/test_ins_complete.vim | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 9aa3881724..8f7d2cb278 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -986,5 +986,13 @@ func Test_ins_complete_add() bwipe! endfunc +func Test_ins_complete_end_of_line() + " this was reading past the end of the line + new + norm 8o€ý  + sil! norm o + + bwipe! +endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit From cabc1861c478b36570bc8d6633097cd4729b8303 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 25 Aug 2022 07:45:00 +0800 Subject: vim-patch:8.2.3989: some insert completion code is not tested Problem: Some insert completion code is not tested. Solution: Add a few tests. Refactor thesaurus completion. (Yegappan Lakshmanan, closes vim/vim#9460) https://github.com/vim/vim/commit/e982586f8eebf2b055987218f6d3f7a084c4bf69 vim-patch:9.0.0254: typo in function name Problem: Typo in function name. Solution: Rename the function. (closes vim/vim#10971) https://github.com/vim/vim/commit/5fb3aabc2b0edd5573e107bb3bc103c348771f61 --- src/nvim/testdir/test_ins_complete.vim | 101 +++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 8f7d2cb278..914d818eef 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -682,6 +682,21 @@ func Test_complete_func_error() call assert_equal([], complete_info(['items']).items) endfunc +" Test for recursively starting completion mode using complete() +func Test_recursive_complete_func() + func ListColors() + call complete(5, ["red", "blue"]) + return '' + endfunc + new + call setline(1, ['a1', 'a2']) + set complete=. + exe "normal Goa\\\=ListColors()\\" + call assert_equal('a2blue', getline(3)) + delfunc ListColors + bw! +endfunc + " Test for completing words following a completed word in a line func Test_complete_wrapscan() " complete words from another buffer @@ -905,6 +920,92 @@ func Test_issue_7021() set completeslash= endfunc +" Test for 'longest' setting in 'completeopt' with latin1 and utf-8 encodings +func Test_complete_longest_match() + " for e in ['latin1', 'utf-8'] + for e in ['utf-8'] + exe 'set encoding=' .. e + new + set complete=. + set completeopt=menu,longest + call setline(1, ['pfx_a1', 'pfx_a12', 'pfx_a123', 'pfx_b1']) + exe "normal Gopfx\" + call assert_equal('pfx_', getline(5)) + bw! + endfor + + " Test for completing additional words with longest match set + new + call setline(1, ['abc1', 'abd2']) + exe "normal Goab\\\" + call assert_equal('ab', getline(3)) + bw! + set complete& completeopt& +endfunc + +" Test for removing the first displayed completion match and selecting the +" match just before that. +func Test_complete_erase_firstmatch() + new + call setline(1, ['a12', 'a34', 'a56']) + set complete=. + exe "normal Goa\\\3\" + call assert_equal('a34', getline('$')) + set complete& + bw! +endfunc + +" Test for completing whole lines from unloaded buffers +func Test_complete_wholeline_unloadedbuf() + call writefile(['a line1', 'a line2', 'a line3'], "Xfile1") + edit Xfile1 + enew + set complete=u + exe "normal! ia\\\" + call assert_equal('a line2', getline(1)) + %d + " completing from an unlisted buffer should fail + bdel Xfile1 + exe "normal! ia\\\" + call assert_equal('a', getline(1)) + set complete& + %bw! + call delete("Xfile1") +endfunc + +" Test for completing whole lines from unlisted buffers +func Test_complete_wholeline_unlistedbuf() + call writefile(['a line1', 'a line2', 'a line3'], "Xfile1") + edit Xfile1 + enew + set complete=U + " completing from a unloaded buffer should fail + exe "normal! ia\\\" + call assert_equal('a', getline(1)) + %d + bdel Xfile1 + exe "normal! ia\\\" + call assert_equal('a line2', getline(1)) + set complete& + %bw! + call delete("Xfile1") +endfunc + +" Test for adding a multibyte character using CTRL-L in completion mode +func Test_complete_mbyte_char_add() + new + set complete=. + call setline(1, 'abė') + exe "normal! oa\\\\\" + call assert_equal('abė', getline(2)) + " Test for a leader with multibyte character + %d + call setline(1, 'abėĕ') + exe "normal! oabė\" + call assert_equal('abėĕ', getline(2)) + bw! +endfunc + " Test to ensure 'Scanning...' messages are not recorded in messages history func Test_z1_complete_no_history() new -- cgit From 3290e472c09c126c014411c73a17d0b1827a795f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 25 Aug 2022 08:04:25 +0800 Subject: vim-patch:8.2.4037: Insert mode completion is insufficiently tested Problem: Insert mode completion is insufficiently tested. Solution: Add more tests. Fix uncovered memory leak. (Yegappan Lakshmanan, closes vim/vim#9489) https://github.com/vim/vim/commit/370791465e745354d66696de8cbd15504cf958c0 --- src/nvim/testdir/test_ins_complete.vim | 235 +++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 914d818eef..3e563f29f9 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -68,6 +68,11 @@ func Test_ins_complete() call assert_equal('Xtest11.one', getline('.')) normal ddk + " Test for expanding a non-existing filename + exe "normal oa1b2X3Y4\\" + call assert_equal('a1b2X3Y4', getline('.')) + normal ddk + set cpt=w " checks make_cyclic in other window exe "normal oST\\\\\" @@ -955,6 +960,27 @@ func Test_complete_erase_firstmatch() bw! endfunc +" Test for completing words from unloaded buffers +func Test_complete_from_unloadedbuf() + call writefile(['abc'], "Xfile1") + call writefile(['def'], "Xfile2") + edit Xfile1 + edit Xfile2 + new | close + enew + bunload Xfile1 Xfile2 + set complete=u + " complete from an unloaded buffer + exe "normal! ia\" + call assert_equal('abc', getline(1)) + exe "normal! od\" + call assert_equal('def', getline(2)) + set complete& + %bw! + call delete("Xfile1") + call delete("Xfile2") +endfunc + " Test for completing whole lines from unloaded buffers func Test_complete_wholeline_unloadedbuf() call writefile(['a line1', 'a line2', 'a line3'], "Xfile1") @@ -973,6 +999,26 @@ func Test_complete_wholeline_unloadedbuf() call delete("Xfile1") endfunc +" Test for completing words from unlisted buffers +func Test_complete_from_unlistedbuf() + call writefile(['abc'], "Xfile1") + call writefile(['def'], "Xfile2") + edit Xfile1 + edit Xfile2 + new | close + bdel Xfile1 Xfile2 + set complete=U + " complete from an unlisted buffer + exe "normal! ia\" + call assert_equal('abc', getline(1)) + exe "normal! od\" + call assert_equal('def', getline(2)) + set complete& + %bw! + call delete("Xfile1") + call delete("Xfile2") +endfunc + " Test for completing whole lines from unlisted buffers func Test_complete_wholeline_unlistedbuf() call writefile(['a line1', 'a line2', 'a line3'], "Xfile1") @@ -1006,6 +1052,195 @@ func Test_complete_mbyte_char_add() bw! endfunc +" Test for using for local expansion even if 'complete' is set to +" not to complete matches from the local buffer. Also test using multiple +" to cancel the current completion mode. +func Test_complete_local_expansion() + new + set complete=t + call setline(1, ['abc', 'def']) + exe "normal! Go\\" + call assert_equal("def", getline(3)) + exe "normal! Go\" + call assert_equal("", getline(4)) + exe "normal! Go\\" + call assert_equal("abc", getline(5)) + exe "normal! Go\" + call assert_equal("", getline(6)) + + " use multiple to cancel the previous completion mode + exe "normal! Go\\\" + call assert_equal("", getline(7)) + exe "normal! Go\\\\" + call assert_equal("", getline(8)) + exe "normal! Go\\\\\" + call assert_equal("abc", getline(9)) + + " interrupt the current completion mode + set completeopt=menu,noinsert + exe "normal! Go\\\\\\" + call assert_equal("abc", getline(10)) + + " when only one is used to interrupt, do normal expansion + exe "normal! Go\\\\" + call assert_equal("", getline(11)) + set completeopt& + + " using two in non-completion mode and restarting the same mode + exe "normal! God\\\\\\\" + call assert_equal("def", getline(12)) + + " test for adding a match from the original empty text + %d + call setline(1, 'abc def g') + exe "normal! o\\\\\" + call assert_equal('def', getline(2)) + exe "normal! 0C\\\\\" + call assert_equal('abc', getline(2)) + + bw! +endfunc + +" Test for undoing changes after a insert-mode completion +func Test_complete_undo() + new + set complete=. + " undo with 'ignorecase' + call setline(1, ['ABOVE', 'BELOW']) + set ignorecase + exe "normal! Goab\u\" + call assert_equal("ABOVE", getline(3)) + undo + call assert_equal("ab", getline(3)) + set ignorecase& + %d + " undo with longest match + set completeopt=menu,longest + call setline(1, ['above', 'about']) + exe "normal! Goa\u\" + call assert_equal("abo", getline(3)) + undo + call assert_equal("a", getline(3)) + set completeopt& + %d + " undo for line completion + call setline(1, ['above that change', 'below that change']) + exe "normal! Goabove\u\\" + call assert_equal("above that change", getline(3)) + undo + call assert_equal("above", getline(3)) + + bw! +endfunc + +" Test for completing a very long word +func Test_complete_long_word() + set complete& + new + call setline(1, repeat('x', 950) .. ' one two three') + exe "normal! Gox\\\\\\\\" + call assert_equal(repeat('x', 950) .. ' one two three', getline(2)) + %d + " should fail when more than 950 characters are in a word + call setline(1, repeat('x', 951) .. ' one two three') + exe "normal! Gox\\\\\\\\" + call assert_equal(repeat('x', 951), getline(2)) + + " Test for adding a very long word to an existing completion + %d + call setline(1, ['abc', repeat('x', 1016) .. '012345']) + exe "normal! Goab\\\" + call assert_equal('abc ' .. repeat('x', 1016) .. '0123', getline(3)) + bw! +endfunc + +" Test for some fields in the complete items used by complete() +func Test_complete_items() + func CompleteItems(idx) + let items = [[#{word: "one", dup: 1, user_data: 'u1'}, #{word: "one", dup: 1, user_data: 'u2'}], + \ [#{word: "one", dup: 0, user_data: 'u3'}, #{word: "one", dup: 0, user_data: 'u4'}], + \ [#{word: "one", icase: 1, user_data: 'u7'}, #{word: "oNE", icase: 1, user_data: 'u8'}], + \ [#{user_data: 'u9'}], + \ [#{word: "", user_data: 'u10'}], + \ [#{word: "", empty: 1, user_data: 'u11'}]] + call complete(col('.'), items[a:idx]) + return '' + endfunc + new + exe "normal! i\=CompleteItems(0)\\\" + call assert_equal('u2', v:completed_item.user_data) + call assert_equal('one', getline(1)) + exe "normal! o\=CompleteItems(1)\\" + call assert_equal('u3', v:completed_item.user_data) + call assert_equal('one', getline(2)) + exe "normal! o\=CompleteItems(1)\\" + call assert_equal('', getline(3)) + set completeopt=menu,noinsert + exe "normal! o\=CompleteItems(2)\one\\" + call assert_equal('oNE', getline(4)) + call assert_equal('u8', v:completed_item.user_data) + set completeopt& + exe "normal! o\=CompleteItems(3)\" + call assert_equal('', getline(5)) + exe "normal! o\=CompleteItems(4)\" + call assert_equal('', getline(6)) + exe "normal! o\=CompleteItems(5)\" + call assert_equal('', getline(7)) + call assert_equal('u11', v:completed_item.user_data) + " pass invalid argument to complete() + let cmd = "normal! o\=complete(1, [[]])\" + call assert_fails('exe cmd', 'E730:') + bw! + delfunc CompleteItems +endfunc + +" Test for the "refresh" item in the dict returned by an insert completion +" function +func Test_complete_item_refresh_always() + let g:CallCount = 0 + func! Tcomplete(findstart, base) + if a:findstart + " locate the start of the word + let line = getline('.') + let start = col('.') - 1 + while start > 0 && line[start - 1] =~ '\a' + let start -= 1 + endwhile + return start + else + let g:CallCount += 1 + let res = ["update1", "update12", "update123"] + return #{words: res, refresh: 'always'} + endif + endfunc + new + set completeopt=menu,longest + set completefunc=Tcomplete + exe "normal! iup\\\\\\\" + call assert_equal('up', getline(1)) + call assert_equal(2, g:CallCount) + set completeopt& + set completefunc& + bw! + delfunc Tcomplete +endfunc + +" Test for completing from a thesaurus file without read permission +func Test_complete_unreadable_thesaurus_file() + CheckUnix + CheckNotRoot + + call writefile(['about', 'above'], 'Xfile') + call setfperm('Xfile', '---r--r--') + new + set complete=sXfile + exe "normal! ia\" + call assert_equal('a', getline(1)) + bw! + call delete('Xfile') + set complete& +endfunc + " Test to ensure 'Scanning...' messages are not recorded in messages history func Test_z1_complete_no_history() new -- cgit From 57b731818d3d54dacdace081f6db4a8ce813173d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 24 Sep 2022 21:13:32 +0800 Subject: vim-patch:9.0.0567: 'completeopt' "longest" is not used for complete() Problem: 'completeopt' "longest" is not used for complete(). Solution: Also use "longest" for complete(). (Bjorn Linse, closes vim/vim#11206) https://github.com/vim/vim/commit/87af60c91503e37c9144f8e48022b12994ce2c85 --- src/nvim/testdir/test_ins_complete.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 3e563f29f9..0810bd4adc 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -702,6 +702,26 @@ func Test_recursive_complete_func() bw! endfunc +" Test for using complete() with completeopt+=longest +func Test_complete_with_longest() + inoremap call complete(1, ["iaax", "iaay", "iaaz"]) + new + + " default: insert first match + set completeopt& + call setline(1, ['i']) + exe "normal Aa\\" + call assert_equal('iaax', getline(1)) + + " with longest: insert longest prefix + set completeopt+=longest + call setline(1, ['i']) + exe "normal Aa\\" + call assert_equal('iaa', getline(1)) + set completeopt& +endfunc + + " Test for completing words following a completed word in a line func Test_complete_wrapscan() " complete words from another buffer -- cgit From 0c77dba9a46765c7a769090ae21433efea5bda00 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 24 Sep 2022 21:16:50 +0800 Subject: vim-patch:9.0.0572: insert complete tests leave a mapping behind Problem: Insert complete tests leave a mapping behind. Solution: Use a buffer-local mapping. (closes vim/vim#11211) https://github.com/vim/vim/commit/75f4bafabdcc6bce5cf3e09fee29c634bf102c17 --- src/nvim/testdir/test_ins_complete.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir/test_ins_complete.vim') diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 0810bd4adc..f706322a85 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -704,8 +704,8 @@ endfunc " Test for using complete() with completeopt+=longest func Test_complete_with_longest() - inoremap call complete(1, ["iaax", "iaay", "iaaz"]) new + inoremap call complete(1, ["iaax", "iaay", "iaaz"]) " default: insert first match set completeopt& @@ -719,6 +719,7 @@ func Test_complete_with_longest() exe "normal Aa\\" call assert_equal('iaa', getline(1)) set completeopt& + bwipe! endfunc @@ -1276,7 +1277,7 @@ endfunc " A mapping is not used for the key after CTRL-X. func Test_no_mapping_for_ctrl_x_key() new - inoremap let was_mapped = 'yes' + inoremap let was_mapped = 'yes' setlocal dictionary=README.txt call feedkeys("aexam\\ ", 'xt') call assert_equal('example ', getline(1)) -- cgit