From c2375efe56b3918f83ee143f48fb7a763fa50289 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 12 Feb 2023 17:32:49 +0800 Subject: fix(ui): make sure screen is valid after resizing Problem: When not inside an Ex command, screen_resize() calls update_screen(), which calls screenclear() and set the screen as valid. However, when inside an Ex command, redrawing is postponed so update_screen() screen doesn't do anything, and the screen is still invalid after the resize, causing ui_comp_raw_line() to be no-op until update_screen() is called on the main loop. Solution: Restore the call to screenclear() inside screen_resize() so that the screen is invalid after screen_resize(). Since screenclear() changes redraw type from UPD_CLEAR to UPD_NOT_VALID, it is called at most once for each resize, so this shouldn't change how much code is run in the common (not inside an Ex command) case. --- test/functional/ui/screen_basic_spec.lua | 81 ++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 5 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 3bd2289a73..439021ad87 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -61,6 +61,7 @@ local function screen_tests(linegrid) [5] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Fuchsia}, [6] = {bold = true, foreground = Screen.colors.Fuchsia}, [7] = {bold = true, foreground = Screen.colors.SeaGreen}, + [8] = {foreground = Screen.colors.White, background = Screen.colors.Red}, } ) end) @@ -866,12 +867,9 @@ local function screen_tests(linegrid) end) describe('resize', function() - before_each(function() + it('rebuilds the whole screen', function() screen:try_resize(25, 5) feed('iresize') - end) - - it('rebuilds the whole screen', function() screen:expect([[ resize^ | {0:~ }| @@ -882,6 +880,7 @@ local function screen_tests(linegrid) end) it('has minimum width/height values', function() + feed('iresize') screen:try_resize(1, 1) screen:expect([[ resize^ | @@ -896,7 +895,8 @@ local function screen_tests(linegrid) end) it('VimResized autocommand does not cause invalid UI events #20692 #20759', function() - feed('') + screen:try_resize(25, 5) + feed('iresize') command([[autocmd VimResized * redrawtabline]]) command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]]) command([[autocmd VimResized * let g:echospace = v:echospace]]) @@ -919,6 +919,77 @@ local function screen_tests(linegrid) ]]) eq(29, meths.get_var('echospace')) end) + + it('messages from the same Ex command as resize are visible #22225', function() + feed(':set columns=20 | call') + screen:expect([[ + | + | + | + | + | + | + | + | + | + {1: }| + {8:E471: Argument requi}| + {8:red} | + {7:Press ENTER or type }| + {7:command to continue}^ | + ]]) + feed('') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + feed(':set columns=0') + screen:expect([[ + | + | + | + | + | + {1: }| + {8:E594: Need a}| + {8:t least 12 c}| + {8:olumns: colu}| + {8:mns=0} | + {7:Press ENTER }| + {7:or type comm}| + {7:and to conti}| + {7:nue}^ | + ]]) + feed('') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) end) describe('press enter', function() -- cgit From 22205f36a6213f51f211a67444b335f916a2fa9f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 May 2023 07:46:07 +0800 Subject: fix(api): don't change title when setting buffer in a window (#23492) --- test/functional/ui/screen_basic_spec.lua | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 439021ad87..6b05bd01c2 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear local feed, command = helpers.feed, helpers.command +local curwin = helpers.curwin local insert = helpers.insert local eq = helpers.eq local eval = helpers.eval @@ -189,6 +190,52 @@ local function screen_tests(linegrid) eq(expected, screen.title) end) end) + + it('setting the buffer of another window using RPC', function() + local oldwin = curwin().id + command('split') + meths.win_set_buf(oldwin, buf2) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('setting the buffer of another window using Lua callback', function() + local oldwin = curwin().id + command('split') + exec_lua(string.format([[ + vim.schedule(function() + vim.api.nvim_win_set_buf(%d, %d) + end) + ]], oldwin, buf2)) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('creating a floating window using RPC', function() + meths.open_win(buf2, false, { + relative = 'editor', width = 5, height = 5, row = 0, col = 0, + }) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('creating a floating window using Lua callback', function() + exec_lua(string.format([[ + vim.api.nvim_open_win(%d, false, { + relative = 'editor', width = 5, height = 5, row = 0, col = 0, + }) + ]], buf2)) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) end) end) -- cgit From 36baaf7c1aa0bbc9c80f4512bb1384839c8851ff Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 10 May 2023 00:14:54 +0800 Subject: test: move most title tests to a separate file (#23557) This avoids running title tests twice unnecessarily. --- test/functional/ui/screen_basic_spec.lua | 121 +------------------------------ 1 file changed, 1 insertion(+), 120 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 6b05bd01c2..e1ae76badf 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -2,12 +2,10 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear local feed, command = helpers.feed, helpers.command -local curwin = helpers.curwin local insert = helpers.insert local eq = helpers.eq local eval = helpers.eval -local funcs, meths, exec_lua = helpers.funcs, helpers.meths, helpers.exec_lua -local is_os = helpers.is_os +local funcs, meths = helpers.funcs, helpers.meths describe('screen', function() local screen @@ -120,123 +118,6 @@ local function screen_tests(linegrid) eq(expected, screen.title) end) end) - - it('has correct default title with unnamed file', function() - local expected = '[No Name] - NVIM' - command('set title') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('has correct default title with named file', function() - local expected = (is_os('win') and 'myfile (C:\\mydir) - NVIM' or 'myfile (/mydir) - NVIM') - command('set title') - command(is_os('win') and 'file C:\\mydir\\myfile' or 'file /mydir/myfile') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - describe('is not changed by', function() - local file1 = is_os('win') and 'C:\\mydir\\myfile1' or '/mydir/myfile1' - local file2 = is_os('win') and 'C:\\mydir\\myfile2' or '/mydir/myfile2' - local expected = (is_os('win') and 'myfile1 (C:\\mydir) - NVIM' or 'myfile1 (/mydir) - NVIM') - local buf2 - - before_each(function() - command('edit '..file1) - buf2 = funcs.bufadd(file2) - command('set title') - end) - - it('calling setbufvar() to set an option in a hidden buffer from i_CTRL-R', function() - command([[inoremap =setbufvar(]]..buf2..[[, '&autoindent', 1) ? '' : '']]) - feed('i') - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('an RPC call to nvim_buf_set_option in a hidden buffer', function() - meths.buf_set_option(buf2, 'autoindent', true) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('a Lua callback calling nvim_buf_set_option in a hidden buffer', function() - exec_lua(string.format([[ - vim.schedule(function() - vim.api.nvim_buf_set_option(%d, 'autoindent', true) - end) - ]], buf2)) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('a Lua callback calling nvim_buf_call in a hidden buffer', function() - exec_lua(string.format([[ - vim.schedule(function() - vim.api.nvim_buf_call(%d, function() end) - end) - ]], buf2)) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('setting the buffer of another window using RPC', function() - local oldwin = curwin().id - command('split') - meths.win_set_buf(oldwin, buf2) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('setting the buffer of another window using Lua callback', function() - local oldwin = curwin().id - command('split') - exec_lua(string.format([[ - vim.schedule(function() - vim.api.nvim_win_set_buf(%d, %d) - end) - ]], oldwin, buf2)) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('creating a floating window using RPC', function() - meths.open_win(buf2, false, { - relative = 'editor', width = 5, height = 5, row = 0, col = 0, - }) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('creating a floating window using Lua callback', function() - exec_lua(string.format([[ - vim.api.nvim_open_win(%d, false, { - relative = 'editor', width = 5, height = 5, row = 0, col = 0, - }) - ]], buf2)) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - end) end) describe(':set icon', function() -- 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/ui/screen_basic_spec.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index e1ae76badf..b31e40d4ab 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -828,7 +828,7 @@ local function screen_tests(linegrid) command([[autocmd VimResized * redrawtabline]]) command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]]) command([[autocmd VimResized * let g:echospace = v:echospace]]) - meths.set_option('showtabline', 2) + meths.set_option_value('showtabline', 2, {}) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | @@ -1056,8 +1056,8 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() clear() local screen = Screen.new(100, 100) screen:attach() - eq(100, meths.get_option('lines')) - eq(99, meths.get_option('window')) + eq(100, meths.get_option_value('lines', {})) + eq(99, meths.get_option_value('window', {})) eq(99, meths.win_get_height(0)) feed('1000o') eq(903, funcs.line('w0')) @@ -1071,8 +1071,8 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() eq(903, funcs.line('w0')) feed('G') screen:try_resize(50, 50) - eq(50, meths.get_option('lines')) - eq(49, meths.get_option('window')) + eq(50, meths.get_option_value('lines', {})) + eq(49, meths.get_option_value('window', {})) eq(49, meths.win_get_height(0)) eq(953, funcs.line('w0')) feed('') -- cgit From 43d66c0ebbe43f40a1f76e1635ccef6181c01317 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 11 May 2023 10:48:48 +0800 Subject: fix(ui-ext): send title to newly-attached UI --- test/functional/ui/screen_basic_spec.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index b31e40d4ab..67e3b774b4 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -117,6 +117,12 @@ local function screen_tests(linegrid) screen:expect(function() eq(expected, screen.title) end) + screen:detach() + screen.title = nil + screen:attach() + screen:expect(function() + eq(expected, screen.title) + end) end) end) @@ -128,6 +134,12 @@ local function screen_tests(linegrid) screen:expect(function() eq(expected, screen.icon) end) + screen:detach() + screen.icon = nil + screen:attach() + screen:expect(function() + eq(expected, screen.icon) + end) end) end) -- cgit From fdc8e966a9183c08f2afec0817d03b7417a883b3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 4 Jun 2023 10:49:02 +0800 Subject: fix(ui): don't send empty grid_line with redrawdebug=compositor (#23899) --- test/functional/ui/screen_basic_spec.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 67e3b774b4..5d5be2e807 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -1096,3 +1096,18 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() feed('') eq(953, funcs.line('w0')) end) + +it("showcmd doesn't cause empty grid_line with redrawdebug=compositor #22593", function() + clear() + local screen = Screen.new(30, 2) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, + }) + screen:attach() + command('set showcmd redrawdebug=compositor') + feed('d') + screen:expect{grid=[[ + ^ | + d | + ]]} +end) -- cgit From a8cfdf43bc6226e32679ec59769ea3e48ca26193 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Jul 2023 07:16:41 +0800 Subject: fix(events): trigger VimResume on next UI request (#24426) --- test/functional/ui/screen_basic_spec.lua | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 5d5be2e807..bc9517aa60 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -4,7 +4,6 @@ local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.cl local feed, command = helpers.feed, helpers.command local insert = helpers.insert local eq = helpers.eq -local eval = helpers.eval local funcs, meths = helpers.funcs, helpers.meths describe('screen', function() @@ -64,34 +63,6 @@ local function screen_tests(linegrid) } ) end) - describe(':suspend', function() - it('is forwarded to the UI', function() - local function check() - eq(true, screen.suspended) - end - - command('let g:ev = []') - command('autocmd VimResume * :call add(g:ev, "r")') - command('autocmd VimSuspend * :call add(g:ev, "s")') - - eq(false, screen.suspended) - command('suspend') - eq({ 's', 'r' }, eval('g:ev')) - - screen:expect(check) - screen.suspended = false - - feed('') - eq({ 's', 'r', 's', 'r' }, eval('g:ev')) - - screen:expect(check) - screen.suspended = false - - command('suspend') - eq({ 's', 'r', 's', 'r', 's', 'r' }, eval('g:ev')) - end) - end) - describe('bell/visual bell', function() it('is forwarded to the UI', function() feed('') -- cgit From a9a48d6b5f00241e16e7131c997f0117bc5e9047 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 30 Sep 2023 10:31:55 +0200 Subject: refactor(message): simplify msg_puts_display and use batched grid updates msg_puts_display was more complex than necessary in nvim, as in nvim, it no longer talks directly with a terminal. In particular we don't need to scroll the grid before emiting the last char. The TUI already takes care of things like that, for terminals where it matters. --- test/functional/ui/screen_basic_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index bc9517aa60..7cc1accd3f 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -795,7 +795,7 @@ local function screen_tests(linegrid) screen:try_resize(1, 1) screen:expect([[ resize^ | - {2:-- INSERT -} | + {2:-- INSERT --}| ]]) feed(':ls') -- cgit