From 9b9f8dfcc41ceb80d3970eb58af8ee350b57dc7f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 18 Feb 2023 09:27:10 +0800 Subject: test: make {MATCH:} behave less unexpectedly in screen:expect() Include the rest of the line and allow multiple {MATCH:} patterns. --- test/functional/editor/mark_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua index b3b190ef79..0670176719 100644 --- a/test/functional/editor/mark_spec.lua +++ b/test/functional/editor/mark_spec.lua @@ -413,7 +413,7 @@ describe('named marks view', function() 6 line | ^7 line | 8 line | - {MATCH:.*} | + {MATCH:.*marks} | | ]]) end) -- cgit From 8065fc9aaeff734f38109aec52bf852379a5a183 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Mar 2023 20:12:58 +0800 Subject: fix(edit): don't subtract msg_scrolled when removing double quote (#22630) With msg_grid there is no need to subtract msg_scrolled. --- test/functional/editor/mode_insert_spec.lua | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test/functional/editor') diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua index cd51a65be3..b00661ac3a 100644 --- a/test/functional/editor/mode_insert_spec.lua +++ b/test/functional/editor/mode_insert_spec.lua @@ -1,6 +1,7 @@ -- Insert-mode tests. local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local expect = helpers.expect local command = helpers.command @@ -48,6 +49,48 @@ describe('insert-mode', function() feed('i"') expect('påskägg') end) + + it('double quote is removed after hit-enter prompt #22609', function() + local screen = Screen.new(60, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, + [1] = {foreground = Screen.colors.Blue}, + [2] = {foreground = Screen.colors.SlateBlue}, + [3] = {bold = true}, + [4] = {reverse = true, bold = true}, + [5] = {background = Screen.colors.Red, foreground = Screen.colors.Red}, + [6] = {background = Screen.colors.Red, foreground = Screen.colors.White}, + [7] = {foreground = Screen.colors.SeaGreen, bold = true}, + }) + screen:attach() + feed('i') + screen:expect([[ + {1:^"} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + feed('={}') + screen:expect([[ + {1:"} | + {0:~ }| + {4: }| + ={5:{}{2:}} | + {6:E731: using Dictionary as a String} | + {7:Press ENTER or type command to continue}^ | + ]]) + feed('') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end) end) describe('Ctrl-O', function() -- cgit From fe9cbcb3a5c82932ecfb8f49d07e98a1fc2b31e5 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Sat, 25 Mar 2023 18:58:48 +0200 Subject: feat(api): nvim_exec2(), deprecate nvim_exec() #19032 Problem: The signature of nvim_exec() is not extensible per ":help api-contract". Solution: Introduce nvim_exec2() and deprecate nvim_exec(). --- test/functional/editor/mark_spec.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua index 0670176719..365f8527a0 100644 --- a/test/functional/editor/mark_spec.lua +++ b/test/functional/editor/mark_spec.lua @@ -40,59 +40,59 @@ describe('named marks', function() it("errors when set out of range with :mark", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "1000mark x") - eq("nvim_exec(): Vim(mark):E16: Invalid range: 1000mark x", err) + eq("nvim_exec2(): Vim(mark):E16: Invalid range: 1000mark x", err) end) it("errors when set out of range with :k", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "1000kx") - eq("nvim_exec(): Vim(k):E16: Invalid range: 1000kx", err) + eq("nvim_exec2(): Vim(k):E16: Invalid range: 1000kx", err) end) it("errors on unknown mark name with :mark", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "mark #") - eq("nvim_exec(): Vim(mark):E191: Argument must be a letter or forward/backward quote", err) + eq("nvim_exec2(): Vim(mark):E191: Argument must be a letter or forward/backward quote", err) end) it("errors on unknown mark name with '", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! '#") - eq("nvim_exec(): Vim(normal):E78: Unknown mark", err) + eq("nvim_exec2(): Vim(normal):E78: Unknown mark", err) end) it("errors on unknown mark name with `", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! `#") - eq("nvim_exec(): Vim(normal):E78: Unknown mark", err) + eq("nvim_exec2(): Vim(normal):E78: Unknown mark", err) end) it("errors when moving to a mark that is not set with '", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! 'z") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) err = pcall_err(helpers.exec_capture, "normal! '.") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) end) it("errors when moving to a mark that is not set with `", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! `z") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) err = pcall_err(helpers.exec_capture, "normal! `>") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) end) it("errors when moving to a global mark that is not set with '", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! 'Z") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) end) it("errors when moving to a global mark that is not set with `", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! `Z") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) end) it("can move to them using '", function() @@ -153,7 +153,7 @@ describe('named marks', function() command("next") command("bw! " .. file1 ) local err = pcall_err(helpers.exec_capture, "normal! 'A") - eq("nvim_exec(): Vim(normal):E92: Buffer 1 not found", err) + eq("nvim_exec2(): Vim(normal):E92: Buffer 1 not found", err) os.remove(file1) end) -- cgit From 4eef5ac453866dae7c03f5432fc8c4dfcda19f54 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Mar 2023 09:24:04 +0800 Subject: vim-patch:9.0.1428: cursor in wrong position when leaving insert mode (#22786) Problem: Cursor in wrong position when leaving insert mode. Solution: Update the w_valid flags. Position the cursor also when not redrawing. (closes vim/vim#12137) https://github.com/vim/vim/commit/c174c2e58c9e24a75b189e01143e6d057b84e96e Co-authored-by: Bram Moolenaar --- test/functional/editor/mode_insert_spec.lua | 30 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua index b00661ac3a..6f16b4e685 100644 --- a/test/functional/editor/mode_insert_spec.lua +++ b/test/functional/editor/mode_insert_spec.lua @@ -53,14 +53,13 @@ describe('insert-mode', function() it('double quote is removed after hit-enter prompt #22609', function() local screen = Screen.new(60, 6) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, - [1] = {foreground = Screen.colors.Blue}, + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {foreground = Screen.colors.Blue}, -- SpecialKey [2] = {foreground = Screen.colors.SlateBlue}, - [3] = {bold = true}, - [4] = {reverse = true, bold = true}, - [5] = {background = Screen.colors.Red, foreground = Screen.colors.Red}, - [6] = {background = Screen.colors.Red, foreground = Screen.colors.White}, - [7] = {foreground = Screen.colors.SeaGreen, bold = true}, + [3] = {bold = true}, -- ModeMsg + [4] = {reverse = true, bold = true}, -- MsgSeparator + [5] = {background = Screen.colors.Red, foreground = Screen.colors.White}, -- ErrorMsg + [6] = {foreground = Screen.colors.SeaGreen, bold = true}, -- MoreMsg }) screen:attach() feed('i') @@ -72,14 +71,23 @@ describe('insert-mode', function() {0:~ }| {3:-- INSERT --} | ]]) - feed('={}') + feed('={}') + screen:expect([[ + {1:"} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ={2:{}}^ | + ]]) + feed('') screen:expect([[ {1:"} | {0:~ }| {4: }| - ={5:{}{2:}} | - {6:E731: using Dictionary as a String} | - {7:Press ENTER or type command to continue}^ | + ={2:{}} | + {5:E731: using Dictionary as a String} | + {6:Press ENTER or type command to continue}^ | ]]) feed('') screen:expect([[ -- cgit From 824639c7c17c4870cde83dd28fed7ed6be0ed4c9 Mon Sep 17 00:00:00 2001 From: Brandon Simmons <34775764+simmsbra@users.noreply.github.com> Date: Thu, 6 Apr 2023 11:08:46 -0500 Subject: fix(folds): handle visual blockwise indent insertion correctly (#22898) Previously, the fold information was incorrect because it wasn't being updated during the blockwise insertion. (Solution by zeertzjq) --- test/functional/editor/fold_spec.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/functional/editor') diff --git a/test/functional/editor/fold_spec.lua b/test/functional/editor/fold_spec.lua index 00e83bedc8..01a30f87bf 100644 --- a/test/functional/editor/fold_spec.lua +++ b/test/functional/editor/fold_spec.lua @@ -359,4 +359,14 @@ a]], '13m7') eq(10, funcs.foldclosedend(7)) eq(14, funcs.foldclosedend(11)) end) + it('updates correctly with indent method and visual blockwise insertion', function() + insert([[ + a + b + ]]) + feed_command('set foldmethod=indent', 'set shiftwidth=2') + feed('gg0jI ') -- indent both lines using visual blockwise mode + eq(1, funcs.foldlevel(1)) + eq(1, funcs.foldlevel(2)) + end) end) -- cgit From 73060f00dd84b2fcfaed74ba061644975707c225 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 7 Apr 2023 09:29:12 +0800 Subject: test: improve editor/fold_spec.lua and editor/put_spec.lua (#22916) - Close and open a new window each time so that window options have their default values in each test. - Change feed_command() to command() as the latter is faster. --- test/functional/editor/fold_spec.lua | 106 +++++++++++++++++++++++++---------- test/functional/editor/put_spec.lua | 39 +++++++------ 2 files changed, 96 insertions(+), 49 deletions(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/fold_spec.lua b/test/functional/editor/fold_spec.lua index 01a30f87bf..3115c20410 100644 --- a/test/functional/editor/fold_spec.lua +++ b/test/functional/editor/fold_spec.lua @@ -4,17 +4,17 @@ local clear = helpers.clear local insert = helpers.insert local feed = helpers.feed local expect = helpers.expect -local feed_command = helpers.feed_command +local command = helpers.command local funcs = helpers.funcs -local foldlevel = funcs.foldlevel -local foldclosedend = funcs.foldclosedend local eq = helpers.eq describe('Folds', function() local tempfname = 'Xtest-fold.txt' - clear() - before_each(function() feed_command('enew!') end) + + setup(clear) + before_each(function() command('bwipe! | new') end) after_each(function() os.remove(tempfname) end) + it('manual folding adjusts with filter', function() insert([[ 1 @@ -37,8 +37,11 @@ describe('Folds', function() 18 19 20]]) - feed_command('4,$fold', '%foldopen', '10,$fold', '%foldopen') - feed_command('1,8! cat') + command('4,$fold') + command('%foldopen') + command('10,$fold') + command('%foldopen') + command('1,8! cat') feed('5ggzdzMGdd') expect([[ 1 @@ -51,22 +54,24 @@ describe('Folds', function() 8 9]]) end) + describe('adjusting folds after :move', function() local function manually_fold_indent() -- setting foldmethod twice is a trick to get vim to set the folds for me - feed_command('set foldmethod=indent', 'set foldmethod=manual') + command('set foldmethod=indent') + command('set foldmethod=manual') -- Ensure that all folds will get closed (makes it easier to test the -- length of folds). - feed_command('set foldminlines=0') + command('set foldminlines=0') -- Start with all folds open (so :move ranges aren't affected by closed -- folds). - feed_command('%foldopen!') + command('%foldopen!') end local function get_folds() local rettab = {} for i = 1, funcs.line('$') do - table.insert(rettab, foldlevel(i)) + table.insert(rettab, funcs.foldlevel(i)) end return rettab end @@ -75,16 +80,16 @@ describe('Folds', function() -- This test is easy because we just need to ensure that the resulting -- fold is the same as calculated when creating folds from scratch. insert(insert_string) - feed_command(move_command) + command(move_command) local after_move_folds = get_folds() -- Doesn't change anything, but does call foldUpdateAll() - feed_command('set foldminlines=0') + command('set foldminlines=0') eq(after_move_folds, get_folds()) -- Set up the buffer with insert_string for the manual fold testing. - feed_command('enew!') + command('enew!') insert(insert_string) manually_fold_indent() - feed_command(move_command) + command(move_command) end it('neither closes nor corrupts folds', function() @@ -130,19 +135,20 @@ a for i = 1,funcs.line('$') do eq(-1, funcs.foldclosed(i)) if i == 1 or i == 7 or i == 13 then - eq(0, foldlevel(i)) + eq(0, funcs.foldlevel(i)) elseif i == 4 then - eq(2, foldlevel(i)) + eq(2, funcs.foldlevel(i)) else - eq(1, foldlevel(i)) + eq(1, funcs.foldlevel(i)) end end -- folds are not corrupted feed('zM') - eq(6, foldclosedend(2)) - eq(12, foldclosedend(8)) - eq(18, foldclosedend(14)) + eq(6, funcs.foldclosedend(2)) + eq(12, funcs.foldclosedend(8)) + eq(18, funcs.foldclosedend(14)) end) + it("doesn't split a fold when the move is within it", function() test_move_indent([[ a @@ -157,6 +163,7 @@ a a]], '5m6') eq({0, 1, 1, 2, 2, 2, 2, 1, 1, 0}, get_folds()) end) + it('truncates folds that end in the moved range', function() test_move_indent([[ a @@ -168,6 +175,7 @@ a a]], '4,5m6') eq({0, 1, 2, 0, 0, 0, 0}, get_folds()) end) + it('moves folds that start between moved range and destination', function() test_move_indent([[ a @@ -185,6 +193,7 @@ a a]], '3,4m$') eq({0, 1, 1, 0, 0, 1, 2, 1, 0, 0, 1, 0, 0}, get_folds()) end) + it('does not affect folds outside changed lines', function() test_move_indent([[ a @@ -198,6 +207,7 @@ a a]], '4m5') eq({1, 1, 1, 0, 0, 0, 1, 1, 1}, get_folds()) end) + it('moves and truncates folds that start in moved range', function() test_move_indent([[ a @@ -212,6 +222,7 @@ a a]], '1,3m7') eq({0, 0, 0, 0, 0, 1, 2, 0, 0, 0}, get_folds()) end) + it('breaks a fold when moving text into it', function() test_move_indent([[ a @@ -223,6 +234,7 @@ a a]], '$m4') eq({0, 1, 2, 2, 0, 0, 0}, get_folds()) end) + it('adjusts correctly when moving a range backwards', function() test_move_indent([[ a @@ -232,6 +244,7 @@ a a]], '2,3m0') eq({1, 2, 0, 0, 0}, get_folds()) end) + it('handles shifting all remaining folds', function() test_move_indent([[ a @@ -252,6 +265,7 @@ a]], '13m7') eq({1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0}, get_folds()) end) end) + it('updates correctly on :read', function() -- luacheck: ignore 621 helpers.write_file(tempfname, [[ @@ -265,8 +279,10 @@ a]], '13m7') a a ]]) - feed_command('set foldmethod=indent', '2', '%foldopen') - feed_command('read ' .. tempfname) + command('set foldmethod=indent') + command('2') + command('%foldopen') + command('read ' .. tempfname) -- Just to check we have the correct file text. expect([[ a @@ -288,6 +304,7 @@ a]], '13m7') eq(1, funcs.foldlevel(i)) end end) + it('combines folds when removing separating space', function() -- luacheck: ignore 621 insert([[ @@ -300,9 +317,11 @@ a]], '13m7') a a ]]) - feed_command('set foldmethod=indent', '3,5d') + command('set foldmethod=indent') + command('3,5d') eq(5, funcs.foldclosedend(1)) end) + it("doesn't combine folds that have a specified end", function() insert([[ {{{ @@ -314,9 +333,12 @@ a]], '13m7') }}} ]]) - feed_command('set foldmethod=marker', '3,5d', '%foldclose') + command('set foldmethod=marker') + command('3,5d') + command('%foldclose') eq(2, funcs.foldclosedend(1)) end) + it('splits folds according to >N and jI ') -- indent both lines using visual blockwise mode eq(1, funcs.foldlevel(1)) eq(1, funcs.foldlevel(2)) diff --git a/test/functional/editor/put_spec.lua b/test/functional/editor/put_spec.lua index 5050edff5c..fb55b71e43 100644 --- a/test/functional/editor/put_spec.lua +++ b/test/functional/editor/put_spec.lua @@ -9,22 +9,21 @@ local eq = helpers.eq local map = helpers.tbl_map local filter = helpers.tbl_filter local feed_command = helpers.feed_command +local command = helpers.command local curbuf_contents = helpers.curbuf_contents local funcs = helpers.funcs local dedent = helpers.dedent -local getreg = funcs.getreg local function reset() - feed_command('enew!') + command('bwipe! | new') insert([[ Line of words 1 Line of words 2]]) - feed_command('goto 1') + command('goto 1') feed('itest_string.u') funcs.setreg('a', 'test_stringa', 'V') funcs.setreg('b', 'test_stringb\ntest_stringb\ntest_stringb', 'b') funcs.setreg('"', 'test_string"', 'v') - feed_command('set virtualedit=') end -- We check the last inserted register ". in each of these tests because it is @@ -508,10 +507,10 @@ describe('put command', function() test_expect(exception_table, after_redo) if selection_string then if not conversion_table.put_backwards then - eq(selection_string, getreg('"')) + eq(selection_string, funcs.getreg('"')) end else - eq('test_string"', getreg('"')) + eq('test_string"', funcs.getreg('"')) end end end @@ -644,7 +643,7 @@ describe('put command', function() -- Set curswant to '8' to be at the end of the tab character -- This is where the cursor is put back after the 'u' command. funcs.setpos('.', {0, 2, 1, 0, 8}) - feed_command('set autoindent') + command('set autoindent') end ) end) @@ -655,7 +654,7 @@ describe('put command', function() test_stringx" Line of words 2]] run_normal_mode_tests(test_string, 'p', function() funcs.setline('$', ' Line of words 2') - feed_command('set virtualedit=all') + command('setlocal virtualedit=all') funcs.setpos('.', {0, 2, 1, 2, 3}) end) end) @@ -667,7 +666,7 @@ describe('put command', function() Line of words 2]] run_normal_mode_tests(test_string, 'p', function() funcs.setline('$', ' Line of words 2') - feed_command('set virtualedit=all') + command('setlocal virtualedit=all') funcs.setpos('.', {0, 1, 16, 1, 17}) end, true) end) @@ -717,7 +716,7 @@ describe('put command', function() return function(exception_table, after_redo) test_expect(exception_table, after_redo) if not conversion_table.put_backwards then - eq('Line of words 1\n', getreg('"')) + eq('Line of words 1\n', funcs.getreg('"')) end end end @@ -753,7 +752,7 @@ describe('put command', function() return function(e,c) test_expect(e,c) if not conversion_table.put_backwards then - eq('Lin\nLin', getreg('"')) + eq('Lin\nLin', funcs.getreg('"')) end end end @@ -836,7 +835,7 @@ describe('put command', function() 'vp', function() funcs.setline('$', ' Line of words 2') - feed_command('set virtualedit=all') + command('setlocal virtualedit=all') funcs.setpos('.', {0, 2, 1, 2, 3}) end, nil, @@ -851,7 +850,7 @@ describe('put command', function() base_expect_string, 'vp', function() - feed_command('set virtualedit=all') + command('setlocal virtualedit=all') funcs.setpos('.', {0, 1, 16, 2, 18}) end, true, @@ -920,12 +919,12 @@ describe('put command', function() end) it('should ring the bell when deleting if not appropriate', function() - feed_command('goto 2') - feed('i') - expect([[ - ine of words 1 - Line of words 2]]) - bell_test(function() feed('".P') end, true) + command('goto 2') + feed('i') + expect([[ + ine of words 1 + Line of words 2]]) + bell_test(function() feed('".P') end, true) end) it('should restore cursor position after undo of ".p', function() @@ -935,7 +934,7 @@ describe('put command', function() end) it("should be unaffected by 'autoindent' with V\".2p", function() - feed_command('set autoindent') + command('set autoindent') feed('i test_string.u') feed('V".2p') expect([[ -- cgit From 0451391ec514eb83c7e366b80fcab21de9f8d4ed Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 10 Apr 2023 22:49:32 +0800 Subject: fix(mark): properly init mark views (#22996) --- test/functional/editor/mark_spec.lua | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'test/functional/editor') diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua index 365f8527a0..a6e4b0c5eb 100644 --- a/test/functional/editor/mark_spec.lua +++ b/test/functional/editor/mark_spec.lua @@ -417,4 +417,48 @@ describe('named marks view', function() | ]]) end) + + it('fallback to standard behavior when mark is loaded from shada', function() + local screen = Screen.new(10, 6) + screen:attach() + command('edit ' .. file1) + feed('G') + feed('mA') + screen:expect([[ + 26 line | + 27 line | + 28 line | + 29 line | + ^30 line | + | + ]]) + command('set shadafile=Xtestfile-functional-editor-marks-shada') + finally(function() + command('set shadafile=NONE') + os.remove('Xtestfile-functional-editor-marks-shada') + end) + command('wshada!') + command('bwipe!') + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + ~ | + | + ]]) + command('rshada!') + command('edit ' .. file1) + feed('`"') + screen:expect([[ + 26 line | + 27 line | + 28 line | + 29 line | + ^30 line | + | + ]]) + feed('`A') + screen:expect_unchanged() + end) end) -- cgit From d321deb4a9b05e9d81b79ac166274f4a6e7981bf Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 27 Apr 2023 15:51:44 +0800 Subject: test: fix dependencies between test cases (#23343) Discovered using --shuffle argument of busted. --- test/functional/editor/fold_spec.lua | 22 +++++++++++----------- test/functional/editor/put_spec.lua | 2 ++ 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/fold_spec.lua b/test/functional/editor/fold_spec.lua index 3115c20410..0ed9d1ba80 100644 --- a/test/functional/editor/fold_spec.lua +++ b/test/functional/editor/fold_spec.lua @@ -58,11 +58,11 @@ describe('Folds', function() describe('adjusting folds after :move', function() local function manually_fold_indent() -- setting foldmethod twice is a trick to get vim to set the folds for me - command('set foldmethod=indent') - command('set foldmethod=manual') + command('setlocal foldmethod=indent') + command('setlocal foldmethod=manual') -- Ensure that all folds will get closed (makes it easier to test the -- length of folds). - command('set foldminlines=0') + command('setlocal foldminlines=0') -- Start with all folds open (so :move ranges aren't affected by closed -- folds). command('%foldopen!') @@ -83,7 +83,7 @@ describe('Folds', function() command(move_command) local after_move_folds = get_folds() -- Doesn't change anything, but does call foldUpdateAll() - command('set foldminlines=0') + command('setlocal foldminlines=0') eq(after_move_folds, get_folds()) -- Set up the buffer with insert_string for the manual fold testing. command('enew!') @@ -279,7 +279,7 @@ a]], '13m7') a a ]]) - command('set foldmethod=indent') + command('setlocal foldmethod=indent') command('2') command('%foldopen') command('read ' .. tempfname) @@ -317,7 +317,7 @@ a]], '13m7') a a ]]) - command('set foldmethod=indent') + command('setlocal foldmethod=indent') command('3,5d') eq(5, funcs.foldclosedend(1)) end) @@ -333,7 +333,7 @@ a]], '13m7') }}} ]]) - command('set foldmethod=marker') + command('setlocal foldmethod=marker') command('3,5d') command('%foldclose') eq(2, funcs.foldclosedend(1)) @@ -372,7 +372,7 @@ a]], '13m7') a a ]]) - command('set foldmethod=expr foldexpr=TestFoldExpr(v:lnum)') + command('setlocal foldmethod=expr foldexpr=TestFoldExpr(v:lnum)') command('2') command('foldopen') command('read ' .. tempfname) @@ -386,7 +386,7 @@ a]], '13m7') end) it('no folds remain if :delete makes buffer empty #19671', function() - command('set foldmethod=manual') + command('setlocal foldmethod=manual') funcs.setline(1, {'foo', 'bar', 'baz'}) command('2,3fold') command('%delete') @@ -394,7 +394,7 @@ a]], '13m7') end) it('multibyte fold markers work #20438', function() - command('set foldmethod=marker foldmarker=«,» commentstring=/*%s*/') + command('setlocal foldmethod=marker foldmarker=«,» commentstring=/*%s*/') insert([[ bbbbb bbbbb @@ -412,7 +412,7 @@ a]], '13m7') a b ]]) - command('set foldmethod=indent shiftwidth=2') + command('setlocal foldmethod=indent shiftwidth=2') feed('gg0jI ') -- indent both lines using visual blockwise mode eq(1, funcs.foldlevel(1)) eq(1, funcs.foldlevel(2)) diff --git a/test/functional/editor/put_spec.lua b/test/functional/editor/put_spec.lua index fb55b71e43..47068470bb 100644 --- a/test/functional/editor/put_spec.lua +++ b/test/functional/editor/put_spec.lua @@ -902,6 +902,8 @@ describe('put command', function() end end end, unchanged=(not should_ring)} + screen.bell = false + screen.visualbell = false end it('should not ring the bell with gp at end of line', function() -- cgit From 75119fcc86e055895af824f7fdbba2f42c1cbbe8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 5 May 2023 07:02:43 +0800 Subject: vim-patch:8.2.3135: Vim9: builtin function arguments not checked at compile time Problem: Vim9: builtin function arguments not checked at compile time. Solution: Add more type checks. (Yegappan Lakshmanan, closes vim/vim#8539) https://github.com/vim/vim/commit/5b73992d8f82be7ac4b6f46c17f53ffb9640e5fa Co-authored-by: Yegappan Lakshmanan --- test/functional/editor/mode_insert_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua index 6f16b4e685..12f450520a 100644 --- a/test/functional/editor/mode_insert_spec.lua +++ b/test/functional/editor/mode_insert_spec.lua @@ -86,7 +86,7 @@ describe('insert-mode', function() {0:~ }| {4: }| ={2:{}} | - {5:E731: using Dictionary as a String} | + {5:E731: Using a Dictionary as a String} | {6:Press ENTER or type command to continue}^ | ]]) feed('') -- cgit From 1fe1bb084d0099fc4f9bfdc11189485d0f74b75a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 19 Dec 2022 16:37:45 +0000 Subject: refactor(options): deprecate nvim[_buf|_win]_[gs]et_option Co-authored-by: zeertzjq Co-authored-by: famiu --- test/functional/editor/K_spec.lua | 2 +- test/functional/editor/completion_spec.lua | 2 +- test/functional/editor/mode_cmdline_spec.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/K_spec.lua b/test/functional/editor/K_spec.lua index 3b5580540f..b964fb3467 100644 --- a/test/functional/editor/K_spec.lua +++ b/test/functional/editor/K_spec.lua @@ -59,7 +59,7 @@ describe('K', function() end) it('empty string falls back to :help #19298', function() - meths.set_option('keywordprg', '') + meths.set_option_value('keywordprg', '', {}) meths.buf_set_lines(0, 0, -1, true, {'doesnotexist'}) feed('K') eq('E149: Sorry, no help for doesnotexist', meths.get_vvar('errmsg')) diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index 22857efe5b..dcd7ef720f 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -988,7 +988,7 @@ describe('completion', function() return '' endfunction ]]) - meths.set_option('completeopt', 'menuone,noselect') + meths.set_option_value('completeopt', 'menuone,noselect', {}) meths.set_var('_complist', {{ word=0, abbr=1, diff --git a/test/functional/editor/mode_cmdline_spec.lua b/test/functional/editor/mode_cmdline_spec.lua index 50cc5e17ee..fcd75ae3b6 100644 --- a/test/functional/editor/mode_cmdline_spec.lua +++ b/test/functional/editor/mode_cmdline_spec.lua @@ -55,7 +55,7 @@ describe('cmdline', function() it('correctly clears end of the history', function() -- Regression test: check absence of the memory leak when clearing end of -- the history using ex_getln.c/clr_history(). - meths.set_option('history', 1) + meths.set_option_value('history', 1, {}) eq(1, funcs.histadd(':', 'foo')) eq(1, funcs.histdel(':')) eq('', funcs.histget(':', -1)) -- cgit From a741c7fd0465c949a0016fcbee5f4526b65f8c02 Mon Sep 17 00:00:00 2001 From: Alexandre Teoi Date: Sat, 1 Jul 2023 10:33:51 -0300 Subject: fix(api): nvim_parse_cmd error message in pcall() #23297 Problem: nvim_parse_cmd() in pcall() may show an error message (side-effect): :lua pcall(vim.api.nvim_parse_cmd, vim.fn.getcmdline(), {}) E16: Invalid range Solution: Avoid emsg() in the nvim_parse_cmd() codepath. - refactor(api): add error message output parameter to get_address() - fix: null check emsg() parameter - refactor: remove emsg_off workaround from do_incsearch_highlighting() - refactor: remove emsg_off workaround from cmdpreview_may_show() - refactor: remove remaining calls to emsg() from parse_cmd_address() and get_address() - (refactor): lint set_cmd_dflall_range() - refactor: addr_error() - move output parameter to return value Fix #20339 TODO: These are the functions called by `get_address()`: ``` nvim_parse_cmd() -> parse_cmdline() -> parse_cmd_address() -> get_address() skipwhite() addr_error() qf_get_cur_idx() qf_get_cur_valid_idx() qf_get_size() qf_get_valid_size() mark_get() mark_check() assert() skip_regexp() magic_isset() > do_search() > searchit() ascii_isdigit() getdigits() getdigits_int32() compute_buffer_local_count() hasFolding() ``` From these functions, I found at least two that call emsg directly: - do_search() - seems to be simple to refactor - searchit() - will be more challenging because it may generate multiple error messages, which can't be handled by the current `errormsg` out-parameter. For example, it makes multiple calls to `vim_regexec_multi()` in a loop that possibly generate error messages, and later `searchit()` itself may generate another one: - https://github.com/neovim/neovim/blob/c194acbfc479d8e5839fa629363f93f6550d035c/src/nvim/search.c#L631-L647 - https://github.com/neovim/neovim/blob/c194acbfc479d8e5839fa629363f93f6550d035c/src/nvim/search.c#L939-L954 --------- Co-authored-by: Justin M. Keyes --- test/functional/editor/mark_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua index a6e4b0c5eb..36485ded7a 100644 --- a/test/functional/editor/mark_spec.lua +++ b/test/functional/editor/mark_spec.lua @@ -161,7 +161,7 @@ describe('named marks', function() feed('ifoomA') command('enew') feed('ibar') - eq('Vim(print):E20: Mark not set', pcall_err(command, [['Aprint]])) + eq("Vim(print):E20: Mark not set: 'Aprint", pcall_err(command, [['Aprint]])) end) it("leave a context mark when moving with '", function() -- cgit From 58f94861442d182e153ba56b63b5b9845b295d2f Mon Sep 17 00:00:00 2001 From: Brandon Simmons <34775764+simmsbra@users.noreply.github.com> Date: Thu, 20 Jul 2023 19:56:08 -0500 Subject: fix(folds): update folds in Insert mode with fdm=indent (#24402) Previously, when using foldmethod=indent, inserting an unindented line would inadvertently open closed folds below it. As a performance improvement, folds were only updated once, across all lines, after Insert mode was exited. Now, the performance improvement is no longer being used when foldmethod=indent, so folds are updated multiple times during Insert mode, but only across the lines that are changing, which preserves the folds (and their open/close states) instead of recreating them. --- test/functional/editor/fold_spec.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/functional/editor') diff --git a/test/functional/editor/fold_spec.lua b/test/functional/editor/fold_spec.lua index 0ed9d1ba80..424ce839a2 100644 --- a/test/functional/editor/fold_spec.lua +++ b/test/functional/editor/fold_spec.lua @@ -7,6 +7,7 @@ local expect = helpers.expect local command = helpers.command local funcs = helpers.funcs local eq = helpers.eq +local neq = helpers.neq describe('Folds', function() local tempfname = 'Xtest-fold.txt' @@ -417,4 +418,31 @@ a]], '13m7') eq(1, funcs.foldlevel(1)) eq(1, funcs.foldlevel(2)) end) + + it("doesn't open folds with indent method when inserting lower foldlevel line", function() + insert([[ + insert an unindented line under this line + keep the lines under this line folded + keep this line folded 1 + keep this line folded 2 + ]]) + command('set foldmethod=indent shiftwidth=2 noautoindent') + eq(1, funcs.foldlevel(1)) + eq(1, funcs.foldlevel(2)) + eq(2, funcs.foldlevel(3)) + eq(2, funcs.foldlevel(4)) + + feed('zo') -- open the outer fold + neq(-1, funcs.foldclosed(3)) -- make sure the inner fold is not open + + feed('gg0oa') -- insert unindented line + + eq(1, funcs.foldlevel(1)) --| insert an unindented line under this line + eq(0, funcs.foldlevel(2)) --|a + eq(1, funcs.foldlevel(3)) --| keep the lines under this line folded + eq(2, funcs.foldlevel(4)) --| keep this line folded 1 + eq(2, funcs.foldlevel(5)) --| keep this line folded 2 + + neq(-1, funcs.foldclosed(4)) -- make sure the inner fold is still not open + end) end) -- cgit From b65f4151d9e52a8521c0682a817c4dab9690e1e7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 27 Sep 2023 18:51:40 +0800 Subject: vim-patch:8.2.3517: TextChanged does not trigger after TextChangedI (#25384) Problem: TextChanged does not trigger after TextChangedI. Solution: Store the tick separately for TextChangedI. (Christian Brabandt, closes vim/vim#8968, closes vim/vim#8932) https://github.com/vim/vim/commit/db3b44640d69ab27270691a3cab8d83cc93a0861 Co-authored-by: Christian Brabandt --- test/functional/editor/completion_spec.lua | 87 ------------------------------ 1 file changed, 87 deletions(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index dcd7ef720f..8c299636cc 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -1032,93 +1032,6 @@ describe('completion', function() ]]) end) - -- oldtest: Test_ChangedP() - it('TextChangedI and TextChangedP autocommands', function() - curbufmeths.set_lines(0, 1, false, { 'foo', 'bar', 'foobar'}) - source([[ - set complete=. completeopt=menuone - let g:foo = [] - autocmd! TextChanged * :call add(g:foo, "N") - autocmd! TextChangedI * :call add(g:foo, "I") - autocmd! TextChangedP * :call add(g:foo, "P") - call cursor(3, 1) - ]]) - - command('let g:foo = []') - feed('o') - poke_eventloop() - feed('') - eq({'I'}, eval('g:foo')) - - command('let g:foo = []') - feed('S') - poke_eventloop() - feed('f') - poke_eventloop() - eq({'I', 'I'}, eval('g:foo')) - feed('') - - command('let g:foo = []') - feed('S') - poke_eventloop() - feed('f') - poke_eventloop() - feed('') - poke_eventloop() - eq({'I', 'I', 'P'}, eval('g:foo')) - feed('') - - command('let g:foo = []') - feed('S') - poke_eventloop() - feed('f') - poke_eventloop() - feed('') - poke_eventloop() - feed('') - poke_eventloop() - eq({'I', 'I', 'P', 'P'}, eval('g:foo')) - feed('') - - command('let g:foo = []') - feed('S') - poke_eventloop() - feed('f') - poke_eventloop() - feed('') - poke_eventloop() - feed('') - poke_eventloop() - feed('') - poke_eventloop() - eq({'I', 'I', 'P', 'P', 'P'}, eval('g:foo')) - feed('') - - command('let g:foo = []') - feed('S') - poke_eventloop() - feed('f') - poke_eventloop() - feed('') - poke_eventloop() - feed('') - poke_eventloop() - feed('') - poke_eventloop() - feed('') - eq({'I', 'I', 'P', 'P', 'P', 'P'}, eval('g:foo')) - feed('') - - eq({'foo', 'bar', 'foobar', 'foo'}, eval('getline(1, "$")')) - - source([[ - au! TextChanged - au! TextChangedI - au! TextChangedP - set complete&vim completeopt&vim - ]]) - end) - it('CompleteChanged autocommand', function() curbufmeths.set_lines(0, 1, false, { 'foo', 'bar', 'foobar', ''}) source([[ -- cgit From 01c51a491330bd10202c73aff92c0978984c0692 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 1 Oct 2023 19:07:16 +0800 Subject: feat(completion): support completing more string options --- test/functional/editor/completion_spec.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/functional/editor') diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index 8c299636cc..ea3397d50d 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -941,6 +941,15 @@ describe('completion', function() end) end) + it('cmdline completion supports various string options', function() + eq('auto', funcs.getcompletion('set foldcolumn=', 'cmdline')[2]) + eq({'nosplit', 'split'}, funcs.getcompletion('set inccommand=', 'cmdline')) + eq({'ver:3,hor:6', 'hor:', 'ver:'}, funcs.getcompletion('set mousescroll=', 'cmdline')) + eq('BS', funcs.getcompletion('set termpastefilter=', 'cmdline')[2]) + eq('SpecialKey', funcs.getcompletion('set winhighlight=', 'cmdline')[1]) + eq('SpecialKey', funcs.getcompletion('set winhighlight=NonText:', 'cmdline')[1]) + end) + describe('from the commandline window', function() it('is cleared after CTRL-C', function () feed('q:') -- cgit From 9f32deba56ea867a8bb9b9ab7f44bcc5142e8bbc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 13 Oct 2023 21:43:06 +0800 Subject: fix(grid): add start column when getting char on line (#25627) --- test/functional/editor/mode_insert_spec.lua | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test/functional/editor') diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua index 12f450520a..37651164f5 100644 --- a/test/functional/editor/mode_insert_spec.lua +++ b/test/functional/editor/mode_insert_spec.lua @@ -192,4 +192,38 @@ describe('insert-mode', function() feed('i') expect('') end) + + it('multi-char mapping updates screen properly #25626', function() + local screen = Screen.new(60, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText + [1] = {bold = true, reverse = true}; -- StatusLine + [2] = {reverse = true}; -- StatusLineNC + [3] = {bold = true}; -- ModeMsg + }) + screen:attach() + command('vnew') + insert('foo\nfoo\nfoo') + command('wincmd w') + command('set timeoutlen=10000') + command('inoremap jk ') + feed('iβββj') + screen:expect{grid=[[ + foo │ | + foo │β^jβ | + foo │{0:~ }| + {0:~ }│{0:~ }| + {2:[No Name] [+] }{1:[No Name] [+] }| + {3:-- INSERT --} | + ]]} + feed('k') + screen:expect{grid=[[ + foo │ | + foo │^βββ | + foo │{0:~ }| + {0:~ }│{0:~ }| + {2:[No Name] [+] }{1:[No Name] [+] }| + | + ]]} + end) end) -- cgit From ae4ca4edf89ece433b61e8bf92c412298b58d9ea Mon Sep 17 00:00:00 2001 From: glepnir Date: Fri, 13 Oct 2023 14:49:01 +0800 Subject: feat(complete): support f flag for complete buffer part --- test/functional/editor/completion_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/functional/editor') diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index ea3397d50d..cb5e0b0b14 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -1228,4 +1228,28 @@ describe('completion', function() expect('colorscheme NOSUCHCOLORSCHEME') assert_alive() end) + + it('complete with f flag #25598', function() + screen:try_resize(20, 9) + local bufname = 'foo/bar.txt' + local hidden = 'fooA/.hidden' + if helpers.is_os('win') then + bufname = 'C:\\foo\\bar.txt' + hidden = 'C:\\fooA\\.hidden' + end + command('set complete+=f | edit '.. bufname ..' | edit '..hidden) + feed('i') + + screen:expect{grid=[[ + foo^ | + {2:foo }{0: }| + {1:bar }{0: }| + {1:txt }{0: }| + {1:fooA }{0: }| + {1:.hidden }{0: }| + {0:~ }| + {0:~ }| + {3:-- }{4:match 1 of 5} | + ]]} + end) end) -- cgit From d432bba4e46cf215a1879cdbe7673160e612425a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 24 Oct 2023 16:10:36 +0800 Subject: fix(marks): handle switching buffer properly (#25763) --- test/functional/editor/jump_spec.lua | 42 ++++++++++++++++++++++++++++++++++++ test/functional/editor/mark_spec.lua | 15 ++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/jump_spec.lua b/test/functional/editor/jump_spec.lua index 63f522fe6e..dc056cb252 100644 --- a/test/functional/editor/jump_spec.lua +++ b/test/functional/editor/jump_spec.lua @@ -48,6 +48,48 @@ describe('jumplist', function() feed('') eq(buf1, funcs.bufnr('%')) end) + + it(' scrolls cursor halfway when switching buffer #25763', function() + write_file(fname1, ('foobar\n'):rep(100)) + write_file(fname2, 'baz') + + local screen = Screen.new(5, 25) + screen:attach() + command('set number') + command('edit '..fname1) + feed('35gg') + command('edit '..fname2) + feed('') + screen:expect{grid=[[ + {1: 24 }foobar | + {1: 25 }foobar | + {1: 26 }foobar | + {1: 27 }foobar | + {1: 28 }foobar | + {1: 29 }foobar | + {1: 30 }foobar | + {1: 31 }foobar | + {1: 32 }foobar | + {1: 33 }foobar | + {1: 34 }foobar | + {1: 35 }^foobar | + {1: 36 }foobar | + {1: 37 }foobar | + {1: 38 }foobar | + {1: 39 }foobar | + {1: 40 }foobar | + {1: 41 }foobar | + {1: 42 }foobar | + {1: 43 }foobar | + {1: 44 }foobar | + {1: 45 }foobar | + {1: 46 }foobar | + {1: 47 }foobar | + | + ]], attr_ids={ + [1] = {foreground = Screen.colors.Brown}; + }} + end) end) describe("jumpoptions=stack behaves like 'tagstack'", function() diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua index 36485ded7a..e669d7f2bb 100644 --- a/test/functional/editor/mark_spec.lua +++ b/test/functional/editor/mark_spec.lua @@ -24,7 +24,6 @@ describe('named marks', function() os.remove(file2) end) - it("can be set", function() command("edit " .. file1) command("mark a") @@ -147,6 +146,20 @@ describe('named marks', function() eq({2, 2}, cursor()) end) + it("can move to them using :'", function() + command("args " .. file1 .. " " .. file2) + feed("j") + feed("ma") + feed("G") + command("'a") + eq({2, 0}, cursor()) + feed("mA") + command("next") + command("'A") + eq(1, meths.get_current_buf().id) + eq({2, 0}, cursor()) + end) + it("errors when it can't find the buffer", function() command("args " .. file1 .. " " .. file2) feed("mA") -- cgit From d1b2a5cf5fa583b556457d34a46ce7b940913a66 Mon Sep 17 00:00:00 2001 From: mortezadadgar Date: Sat, 11 Nov 2023 02:11:10 +0330 Subject: fix(completion): make sure the buffer name is valid (#25975) Problem: crash from set complete+=f open a empty buffer C-N Solution: make sure the buffer name is valid. regression from ae4ca4edf89ece433b61e8bf92c412298b58d9ea --- test/functional/editor/completion_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index cb5e0b0b14..51f30543e3 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -1237,7 +1237,7 @@ describe('completion', function() bufname = 'C:\\foo\\bar.txt' hidden = 'C:\\fooA\\.hidden' end - command('set complete+=f | edit '.. bufname ..' | edit '..hidden) + command('set complete+=f | edit '..bufname..' | edit '..hidden..' | enew') feed('i') screen:expect{grid=[[ -- cgit From cdc8bacc7945da816738e330555fa85d3ffffd56 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 18 Nov 2023 12:26:52 +0800 Subject: fix(completion): filter results with complete+=f (#26029) --- test/functional/editor/completion_spec.lua | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'test/functional/editor') diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index 51f30543e3..cbaf401f06 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -1231,25 +1231,30 @@ describe('completion', function() it('complete with f flag #25598', function() screen:try_resize(20, 9) - local bufname = 'foo/bar.txt' - local hidden = 'fooA/.hidden' - if helpers.is_os('win') then - bufname = 'C:\\foo\\bar.txt' - hidden = 'C:\\fooA\\.hidden' - end - command('set complete+=f | edit '..bufname..' | edit '..hidden..' | enew') + command('set complete+=f | edit foo | edit bar |edit foa |edit .hidden') feed('i') - screen:expect{grid=[[ foo^ | {2:foo }{0: }| {1:bar }{0: }| - {1:txt }{0: }| - {1:fooA }{0: }| + {1:foa }{0: }| {1:.hidden }{0: }| {0:~ }| {0:~ }| - {3:-- }{4:match 1 of 5} | + {0:~ }| + {3:-- }{4:match 1 of 4} | + ]]} + feed('ccf') + screen:expect{grid=[[ + foo^ | + {2:foo }{0: }| + {1:foa }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- }{4:match 1 of 2} | ]]} end) end) -- cgit From e6d38c7dac2e079d9b0f1621fef193bca858664f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Nov 2023 11:46:20 +0800 Subject: vim-patch:9.0.2133: Cannot detect overstrike mode in Cmdline mode (#26263) Problem: Cannot detect overstrike mode in Cmdline mode Solution: Make mode() return "cr" for overstrike closes: vim/vim#13569 https://github.com/vim/vim/commit/d1c3ef1f47c87d1da056c56564e1985fe6f2931d --- test/functional/editor/mode_cmdline_spec.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/functional/editor') diff --git a/test/functional/editor/mode_cmdline_spec.lua b/test/functional/editor/mode_cmdline_spec.lua index fcd75ae3b6..d34b5a1a28 100644 --- a/test/functional/editor/mode_cmdline_spec.lua +++ b/test/functional/editor/mode_cmdline_spec.lua @@ -1,9 +1,11 @@ -- Cmdline-mode tests. local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local clear, insert, funcs, eq, feed = helpers.clear, helpers.insert, helpers.funcs, helpers.eq, helpers.feed local eval = helpers.eval +local command = helpers.command local meths = helpers.meths describe('cmdline', function() @@ -43,6 +45,30 @@ describe('cmdline', function() eq('"', eval('@:')) end) + it('redraws statusline when toggling overstrike', function() + local screen = Screen.new(60, 4) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {reverse = true, bold = true}, -- StatusLine + }) + screen:attach() + command('set laststatus=2 statusline=%!mode(1)') + feed(':') + screen:expect{grid=[[ + | + {0:~ }| + {1:c }| + :^ | + ]]} + feed('') + screen:expect{grid=[[ + | + {0:~ }| + {1:cr }| + :^ | + ]]} + end) + describe('history', function() it('correctly clears start of the history', function() -- Regression test: check absence of the memory leak when clearing start of -- cgit