From d41b8d47587bd4c300420fa76f517298e97af513 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Fri, 15 Mar 2024 00:39:44 +0100 Subject: fix(ui): ext_cmdline should not move cursor to curwin Problem: The ext_cmdline cursor position on the screen seems to rely on an implicit assumption that the event listener implements a cmdline window that is made the current window which is problematic (e.g. breaks 'incsearch' in the actual current window). Solution: Remove this assumption and allow nvim_win_set_cursor() to move the cursor on the screen to a non-current window (previous commit). --- test/functional/ui/cmdline_spec.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 0eb5770819..3b5b488982 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -824,6 +824,29 @@ local function test_cmdline(linegrid) | ]]) end) + + it('does not move cursor to curwin #20309', function() + local win = api.nvim_get_current_win() + command('norm icmdlinewin') + command('new') + command('norm icurwin') + feed(':') + api.nvim_win_set_cursor(win, { 1, 7 }) + screen:expect { + grid = [[ + curwin | + {3:[No Name] [+] }| + cmdline^win | + {2:[No Name] [+] }| + | + ]], + cmdline = { { + content = { { '' } }, + firstc = ':', + pos = 0, + } }, + } + end) end -- the representation of cmdline and cmdline_block contents changed with ext_linegrid -- cgit From 35f2bb05a5cb84af405a094f040b92461a824e61 Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 26 Mar 2024 21:23:36 +0100 Subject: refactor(tests): use new global defaults instead of set_default_attr_ids This will be done in batches. --- test/functional/ui/cmdline_spec.lua | 67 ++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 38 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 3b5b488982..d38cb395e2 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1265,15 +1265,6 @@ describe('cmdheight=0', function() before_each(function() clear() screen = Screen.new(25, 5) - screen:set_default_attr_ids { - [1] = { bold = true, foreground = Screen.colors.Blue }, - [2] = { bold = true, reverse = true }, - [3] = { bold = true }, - [4] = { foreground = Screen.colors.White, background = Screen.colors.Red }, - [5] = { foreground = Screen.colors.SeaGreen4, bold = true }, - [6] = { reverse = true }, - [7] = { background = Screen.colors.Yellow }, - } screen:attach() end) @@ -1302,7 +1293,7 @@ describe('cmdheight=0', function() grid = [[ ^ | {1:~ }|*2 - {2:[No Name] }| + {3:[No Name] }| | ]], } @@ -1314,7 +1305,7 @@ describe('cmdheight=0', function() grid = [[ ^ | {1:~ }|*3 - {2:[No Name] }| + {3:[No Name] }| ]], } end) @@ -1364,7 +1355,7 @@ describe('cmdheight=0', function() grid = [[ ^ | {1:~ }|*3 - {3:-- INSERT --} | + {5:-- INSERT --} | ]], } feed('') @@ -1400,7 +1391,7 @@ describe('cmdheight=0', function() grid = [[ | {1:~ }| - {2: }| + {3: }| :call input("foo >") | foo >^ | ]], @@ -1422,26 +1413,26 @@ describe('cmdheight=0', function() feed(':split') screen:expect { grid = [[ - {2: }| + {3: }| :split | - {4:E36: Not enough room} | - {5:Press ENTER or type comma}| - {5:nd to continue}^ | + {9:E36: Not enough room} | + {6:Press ENTER or type comma}| + {6:nd to continue}^ | ]], } feed('') screen:expect { grid = [[ - {3:foo }| + {5:foo }| ^ | {1:~ }|*2 - {2:[No Name] }| + {3:[No Name] }| ]], } feed(':') screen:expect { grid = [[ - {3:foo }| + {5:foo }| | {1:~ }|*2 :^ | @@ -1450,10 +1441,10 @@ describe('cmdheight=0', function() feed('') screen:expect { grid = [[ - {3:foo }| + {5:foo }| ^ | {1:~ }|*2 - {2:[No Name] }| + {3:[No Name] }| ]], showmode = {}, } @@ -1488,16 +1479,16 @@ describe('cmdheight=0', function() grid = [[ fo^o | {1:~ }|*3 - {2:[No Name] [+] }| + {3:[No Name] [+] }| ]], } feed(':%s/foo/bar/gc') screen:expect { grid = [[ - {6:foo} | + {2:foo} | {1:~ }|*3 - {5:replace wi...q/l/^E/^Y)?}^ | + {6:replace wi...q/l/^E/^Y)?}^ | ]], } @@ -1506,7 +1497,7 @@ describe('cmdheight=0', function() grid = [[ ^bar | {1:~ }|*3 - {2:[No Name] [+] }| + {3:[No Name] [+] }| ]], } @@ -1525,7 +1516,7 @@ describe('cmdheight=0', function() feed('iaabbaa/aa') screen:expect { grid = [[ - {7:^aa}bb{7:aa} | + {10:^aa}bb{10:aa} | {1:~ }|*4 ]], } @@ -1584,7 +1575,7 @@ describe('cmdheight=0', function() [2:-------------------------]|*4 [3:-------------------------]| ## grid 2 - {6:p} | + {2:p} | {1:~ }|*4 ## grid 3 /p^ | @@ -1610,7 +1601,7 @@ describe('cmdheight=0', function() ]]) feed(':') screen:expect([[ - {3:c :}| + {5:c :}| | {1:~ }|*2 :^ | @@ -1618,14 +1609,14 @@ describe('cmdheight=0', function() feed('echo') -- not redrawn yet screen:expect([[ - {3:c :}| + {5:c :}| | {1:~ }|*2 :echo^ | ]]) command('redrawstatus') screen:expect([[ - {3:c :echo}| + {5:c :echo}| | {1:~ }|*2 :echo^ | @@ -1646,7 +1637,7 @@ describe('cmdheight=0', function() screen:expect([[ ^ │ | {1:~ }│{1:~ }|*3 - {2:[No Name] }│{1:~ }| + {3:[No Name] }│{1:~ }| │{1:~ }| {1:~ }│{1:~ }|*3 ]]) @@ -1654,7 +1645,7 @@ describe('cmdheight=0', function() screen:expect([[ ^ │ | {1:~ }│{1:~ }| - {2:[No Name] }│{1:~ }| + {3:[No Name] }│{1:~ }| │{1:~ }| {1:~ }│{1:~ }|*5 ]]) @@ -1664,7 +1655,7 @@ describe('cmdheight=0', function() screen:expect([[ ^ │ | {1:~ }│{1:~ }|*3 - {2:[No Name] }│{1:~ }| + {3:[No Name] }│{1:~ }| │{1:~ }| {1:~ }│{1:~ }|*3 ]]) @@ -1686,7 +1677,7 @@ describe('cmdheight=0', function() screen:expect([[ ^ | {1:~ }|*2 - {2:[No Name] }| + {3:[No Name] }| | ]]) command('set cmdheight=0') @@ -1694,7 +1685,7 @@ describe('cmdheight=0', function() grid = [[ ^ | {1:~ }|*3 - {2:[No Name] }| + {3:[No Name] }| ]], } command('resize -1') @@ -1702,7 +1693,7 @@ describe('cmdheight=0', function() grid = [[ ^ | {1:~ }|*2 - {2:[No Name] }| + {3:[No Name] }| | ]], } @@ -1710,7 +1701,7 @@ describe('cmdheight=0', function() screen:expect([[ ^ | {1:~ }|*3 - {2:[No Name] }| + {3:[No Name] }| ]]) end) -- cgit From a94120752344f04c3f6d7e088026e9a58f46fe64 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 Apr 2024 19:08:03 +0800 Subject: vim-patch:9.0.0581: adding a character for incsearch fails at end of line Problem: Adding a character for incsearch fails at end of line. Solution: Only check cursor line number. https://github.com/vim/vim/commit/d4566c14e71c55dcef05fb34ea94eba835831527 Co-authored-by: Bram Moolenaar --- test/functional/ui/cmdline_spec.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index d38cb395e2..0b2c0af66b 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -365,7 +365,7 @@ local function test_cmdline(linegrid) grid = [[ | {2:[No Name] }| - {1::}mak^e | + {1::}make^ | {3:[Command Line] }| | ]], @@ -377,7 +377,7 @@ local function test_cmdline(linegrid) grid = [[ | {2:[No Name] }| - {1::}mak^e | + {1::}make^ | {3:[Command Line] }| | ]], @@ -396,7 +396,7 @@ local function test_cmdline(linegrid) grid = [[ | {2:[No Name] }| - {1::}mak^e | + {1::}make^ | {3:[Command Line] }| | ]], @@ -416,7 +416,7 @@ local function test_cmdline(linegrid) grid = [[ | {2:[No Name] }| - {1::}mak^e | + {1::}make^ | {3:[Command Line] }| | ]], @@ -1586,7 +1586,7 @@ describe('cmdheight=0', function() topline = 0, botline = 2, curline = 0, - curcol = 0, + curcol = 1, linecount = 1, sum_scroll_delta = 0, }, -- cgit From 7035125b2b26aa68fcfb7cda39377ac79926a0f9 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 8 Apr 2024 11:03:20 +0200 Subject: test: improve test conventions Work on https://github.com/neovim/neovim/issues/27004. --- test/functional/ui/cmdline_spec.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 0b2c0af66b..a3d44f3542 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1,15 +1,15 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) local Screen = require('test.functional.ui.screen') -local clear, feed = helpers.clear, helpers.feed -local source = helpers.source -local command = helpers.command -local assert_alive = helpers.assert_alive -local poke_eventloop = helpers.poke_eventloop -local exec = helpers.exec -local eval = helpers.eval -local eq = helpers.eq -local is_os = helpers.is_os -local api = helpers.api +local clear, feed = t.clear, t.feed +local source = t.source +local command = t.command +local assert_alive = t.assert_alive +local poke_eventloop = t.poke_eventloop +local exec = t.exec +local eval = t.eval +local eq = t.eq +local is_os = t.is_os +local api = t.api local function new_screen(opt) local screen = Screen.new(25, 5) -- cgit From 81fc27124b9e1b375e0ce9605ae69c3c2a2d9222 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 9 Apr 2024 12:26:16 +0100 Subject: refactor(test): inject after_each differently --- test/functional/ui/cmdline_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index a3d44f3542..d3d5cb1093 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local Screen = require('test.functional.ui.screen') local clear, feed = t.clear, t.feed local source = t.source -- cgit From b5a38530ba18b324c739e1d087bd78e4a0a6d4b3 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Fri, 15 Mar 2024 12:54:39 +0100 Subject: fix(ui): don't force 'cmdheight' to zero with ext_messages Remove remaining code that prevents non-zero 'cmdheight' with ext_messages. --- test/functional/ui/cmdline_spec.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index d3d5cb1093..c56cad295a 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1705,19 +1705,24 @@ describe('cmdheight=0', function() ]]) end) - it('cannot be resized at all with external messages', function() + it('can be resized with external messages', function() clear() screen = new_screen({ rgb = true, ext_messages = true }) command('set laststatus=2 mouse=a') command('resize -1') screen:expect([[ ^ | - {1:~ }|*3 + {1:~ }|*2 {3:[No Name] }| + | ]]) - api.nvim_input_mouse('left', 'press', '', 0, 6, 10) + api.nvim_input_mouse('left', 'press', '', 0, 3, 10) poke_eventloop() - api.nvim_input_mouse('left', 'drag', '', 0, 5, 10) - screen:expect_unchanged() + api.nvim_input_mouse('left', 'drag', '', 0, 4, 10) + screen:expect([[ + ^ | + {1:~ }|*3 + {3:[No Name] }| + ]]) end) end) -- cgit From 344906a08f0972108eb912c87af32b275ecf318e Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Sun, 21 Apr 2024 02:15:18 +0200 Subject: fix(api): do not update grid position in nvim_win_set_cursor (#28235) Revert commit c971f538ab87b537ae4c97bd44167661c5691a2d. Forcing grid cursor position will need a new API like originally proposed in #27858. --- test/functional/ui/cmdline_spec.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index d3d5cb1093..84aa153b0e 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -825,7 +825,8 @@ local function test_cmdline(linegrid) ]]) end) - it('does not move cursor to curwin #20309', function() + -- Needs new API + pending('does not move cursor to curwin #20309', function() local win = api.nvim_get_current_win() command('norm icmdlinewin') command('new') -- cgit From 052498ed42780a76daea589d063cd8947a894673 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 20 Apr 2024 17:44:13 +0200 Subject: test: improve test conventions Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004. --- test/functional/ui/cmdline_spec.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 645f3851b2..b3ec5f7535 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1,15 +1,17 @@ -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed = t.clear, t.feed -local source = t.source -local command = t.command -local assert_alive = t.assert_alive -local poke_eventloop = t.poke_eventloop -local exec = t.exec -local eval = t.eval + +local clear, feed = n.clear, n.feed +local source = n.source +local command = n.command +local assert_alive = n.assert_alive +local poke_eventloop = n.poke_eventloop +local exec = n.exec +local eval = n.eval local eq = t.eq local is_os = t.is_os -local api = t.api +local api = n.api local function new_screen(opt) local screen = Screen.new(25, 5) -- cgit From 037ea6e786b5d05f4a8965e4c2ba6aa60ec7c01a Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 10 Apr 2024 11:42:46 +0200 Subject: feat(api): add nvim__redraw for more granular redrawing Experimental and subject to future changes. Add a way to redraw certain elements that are not redrawn while Nvim is waiting for input, or currently have no API to do so. This API covers all that can be done with the :redraw* commands, in addition to the following new features: - Immediately move the cursor to a (non-current) window. - Target a specific window or buffer to mark for redraw. - Mark a buffer range for redraw (replaces nvim__buf_redraw_range()). - Redraw the 'statuscolumn'. --- test/functional/ui/cmdline_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index b3ec5f7535..6edfb4a49c 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -827,14 +827,14 @@ local function test_cmdline(linegrid) ]]) end) - -- Needs new API - pending('does not move cursor to curwin #20309', function() + it('does not move cursor to curwin #20309', function() local win = api.nvim_get_current_win() command('norm icmdlinewin') command('new') command('norm icurwin') feed(':') api.nvim_win_set_cursor(win, { 1, 7 }) + api.nvim__redraw({ win = win, cursor = true }) screen:expect { grid = [[ curwin | -- cgit