From fd2ece278b0941ec6673489e88868120e86b834a Mon Sep 17 00:00:00 2001 From: Matthias Deiml Date: Sun, 12 Mar 2023 23:58:46 +0100 Subject: feat(ui): add scroll_delta to win_viewport event #19270 scroll_delta contains how much the top line of a window moved since the last time win_viewport was emitted. It is expected to be used to implement smooth scrolling. For this purpose it only counts "virtual" or "displayed" so folds should count as one line. Because of this it adds extra information that cannot be computed from the topline parameter. Fixes #19227 --- 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 1c9ac7f7ba..a9469bdf2d 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1241,7 +1241,7 @@ describe('cmdheight=0', function() {1:~ }| ## grid 3 ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} feed '/p' @@ -1261,7 +1261,7 @@ describe('cmdheight=0', function() ## grid 3 /p^ | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} end) -- cgit From 3688735c2b63337ab8d8b12ac08b4e6e064e98a2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 23 Jun 2023 06:40:26 +0800 Subject: fix(cmdline): don't redraw 'tabline' in Ex mode (#24123) Redrawing of 'statusline' and 'winbar' are actually already inhibited by RedawingDisabled in Ex mode. In Vim there is a check for `msg_scrolled == 0` (which is false in Ex mode) since Vim doesn't have msgsep. Add a `!exmode_active` check here in Nvim instead. --- test/functional/ui/cmdline_spec.lua | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 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 a9469bdf2d..dc29b765bd 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -944,6 +944,45 @@ describe('statusline is redrawn on entering cmdline', function() end) end) +it('tabline is not redrawn in Ex mode #24122', function() + clear() + local screen = Screen.new(60, 5) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, reverse = true}, -- MsgSeparator + [2] = {reverse = true}, -- TabLineFill + }) + screen:attach() + + exec([[ + set showtabline=2 + set tabline=%!MyTabLine() + + function! MyTabLine() + + return "foo" + endfunction + ]]) + + feed('gQ') + screen:expect{grid=[[ + {2:foo }| + | + {1: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :^ | + ]]} + + feed('echo 1') + screen:expect{grid=[[ + {1: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :echo 1 | + 1 | + :^ | + ]]} +end) + describe("cmdline height", function() it("does not crash resized screen #14263", function() clear() -- cgit From a47be0b2d90b26905866faf5b7cc82d9c17be9bb Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 24 Jul 2023 11:56:26 +0100 Subject: fix(window): prevent win_size_restore from changing cmdheight Currently it only skips if `Rows` changed, but it's possible for the height of the usable area for windows to change (e.g: via `&ch`, `&stal` or `&ls`), which can cause the value of `&cmdheight` to change when the sizes are restored. This is a Vim bug, so I've submitted a PR there too. No telling when it'll be merged though, given the current lack of activity there. `ROWS_AVAIL` is convenient here, but also subtracts the `global_stl_height()`. Not ideal, as we also care about the height of the last statusline for other values of `&ls`. Meh. Introduce `last_stl_height` for getting the height of the last statusline and use it in `win_size_save/restore` and `last_status` (means `last_status_rec`'s `statusline` argument will now be true if `&ls` is 3, but that does not change the behaviour). Also corrects the logic in `comp_col` to not assume there's a last statusline if `&ls` is 1 and the last window is floating. --- test/functional/ui/cmdline_spec.lua | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 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 dc29b765bd..a8cc8e00f0 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -984,14 +984,46 @@ it('tabline is not redrawn in Ex mode #24122', function() end) describe("cmdline height", function() + before_each(clear) + it("does not crash resized screen #14263", function() - clear() local screen = Screen.new(25, 10) screen:attach() command('set cmdheight=9999') screen:try_resize(25, 5) assert_alive() end) + + it('unchanged when trying to restore window sizes', function() + command('set showtabline=0 cmdheight=2 laststatus=0') + feed('q:') -- Closing cmdwin tries to restore sizes + command('set cmdheight=1 | quit') + eq(1, eval('&cmdheight')) + + command('set showtabline=2 cmdheight=3') + feed('q:') + command('set showtabline=0 | quit') + eq(3, eval('&cmdheight')) + + command('set cmdheight=1 laststatus=2') + feed('q:') + command('set laststatus=0 | quit') + eq(1, eval('&cmdheight')) + + command('set laststatus=2') + feed('q:') + command('set laststatus=1 | quit') + eq(1, eval('&cmdheight')) + + command('set laststatus=2 | belowright vsplit | wincmd _') + local restcmds = eval('winrestcmd()') + feed('q:') + command('set laststatus=1 | quit') + -- As we have 2 windows, &ls = 1 should still have a statusline on the last + -- window. As such, the number of available rows hasn't changed and the window + -- sizes should be restored. + eq(restcmds, eval('winrestcmd()')) + end) end) describe('cmdheight=0', function() -- cgit From 9f7e7455c01718c696e132513fd449235bd4f865 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 17 Aug 2023 23:16:19 +0100 Subject: vim-patch:9.0.1726: incorrect heights in win_size_restore() (#24765) Problem: incorrect heights in win_size_restore() Solution: avoid restoring incorrect heights in win_size_restore() https://github.com/vim/vim/commit/876f5fb570d8401aa4c58af4a5da91f10520aa9d I already merged this prior, so just replace the new test with the old one, but add a test case for the global statusline. --- test/functional/ui/cmdline_spec.lua | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 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 a8cc8e00f0..7d87ba4972 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -994,35 +994,13 @@ describe("cmdline height", function() assert_alive() end) - it('unchanged when trying to restore window sizes', function() - command('set showtabline=0 cmdheight=2 laststatus=0') - feed('q:') -- Closing cmdwin tries to restore sizes - command('set cmdheight=1 | quit') - eq(1, eval('&cmdheight')) - - command('set showtabline=2 cmdheight=3') - feed('q:') - command('set showtabline=0 | quit') - eq(3, eval('&cmdheight')) - - command('set cmdheight=1 laststatus=2') - feed('q:') - command('set laststatus=0 | quit') - eq(1, eval('&cmdheight')) - - command('set laststatus=2') + it('unchanged when restoring window sizes with global statusline', function() + command('set cmdheight=2 laststatus=2') feed('q:') - command('set laststatus=1 | quit') + command('set cmdheight=1 laststatus=3 | quit') + -- Available lines changed, so closing cmdwin should skip restoring window sizes, leaving the + -- cmdheight unchanged. eq(1, eval('&cmdheight')) - - command('set laststatus=2 | belowright vsplit | wincmd _') - local restcmds = eval('winrestcmd()') - feed('q:') - command('set laststatus=1 | quit') - -- As we have 2 windows, &ls = 1 should still have a statusline on the last - -- window. As such, the number of available rows hasn't changed and the window - -- sizes should be restored. - eq(restcmds, eval('winrestcmd()')) end) end) -- cgit From b84a67f50ed6141f72d433094a1a611ae4f67924 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 22 Aug 2023 22:48:55 +0800 Subject: vim-patch:9.0.0579: using freed memory when 'tagfunc' wipes out buffer (#24838) Problem: Using freed memory when 'tagfunc' wipes out buffer that holds 'complete'. Solution: Make a copy of the option. Make sure cursor position is valid. https://github.com/vim/vim/commit/0ff01835a40f549c5c4a550502f62a2ac9ac447c Cherry-pick a cmdwin change from patch 9.0.0500. Co-authored-by: Bram Moolenaar --- test/functional/ui/cmdline_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 7d87ba4972..4b92ab730d 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -316,7 +316,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ | {2:[No Name] }| - {1::}make^ | + {1::}mak^e | {3:[Command Line] }| | ]]} @@ -326,7 +326,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ | {2:[No Name] }| - {1::}make^ | + {1::}mak^e | {3:[Command Line] }| | ]], cmdline={nil, { @@ -339,7 +339,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ | {2:[No Name] }| - {1::}make^ | + {1::}mak^e | {3:[Command Line] }| | ]], cmdline={nil, { @@ -352,7 +352,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ | {2:[No Name] }| - {1::}make^ | + {1::}mak^e | {3:[Command Line] }| | ]]} -- cgit From 380b634ac951acfd24cffc5091bbcfbb39cd8ca3 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 20 Sep 2023 21:51:57 +0200 Subject: fix(test): fix "indeterminism" warnings in UI tests --- test/functional/ui/cmdline_spec.lua | 19 +++++++++++++++++-- 1 file changed, 17 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 4b92ab730d..6baad28dad 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1275,6 +1275,7 @@ describe('cmdheight=0', function() it('with multigrid', function() clear{args={'--cmd', 'set cmdheight=0'}} screen:attach{ext_multigrid=true} + meths.buf_set_lines(0, 0, -1, true, {'p'}) screen:expect{grid=[[ ## grid 1 [2:-------------------------]| @@ -1283,7 +1284,7 @@ describe('cmdheight=0', function() [2:-------------------------]| [2:-------------------------]| ## grid 2 - ^ | + ^p | {1:~ }| {1:~ }| {1:~ }| @@ -1302,7 +1303,7 @@ describe('cmdheight=0', function() [2:-------------------------]| [3:-------------------------]| ## grid 2 - | + {6:p} | {1:~ }| {1:~ }| {1:~ }| @@ -1427,7 +1428,21 @@ describe('cmdheight=0', function() | ]]) command('set cmdheight=0') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {2:[No Name] }| + ]]} command('resize -1') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {2:[No Name] }| + | + ]]} command('resize +1') screen:expect([[ ^ | -- cgit From 0592fd5e17dc3609c148e0ccc25a4f035d5f7153 Mon Sep 17 00:00:00 2001 From: nwounkn Date: Sun, 24 Sep 2023 23:15:33 +0500 Subject: fix(ui): "resize -1" with cmdheight=0 #24758 Problem: Crash from: set cmdheight=0 redrawdebug=invalid resize -1 Solution: Do not invalidate first `p_ch` `msg_grid` rows in `update_screen` when scrolling the screen down after displaying a message, because they may be used later for drawing cmdline. Fixes #22154 --- test/functional/ui/cmdline_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 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 6baad28dad..497b2e7f4c 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1021,6 +1021,26 @@ describe('cmdheight=0', function() screen:attach() end) + it("with redrawdebug=invalid resize -1", function() + command("set redrawdebug=invalid cmdheight=0 noruler laststatus=0") + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + feed(":resize -1") + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + assert_alive() + end) + it("with cmdheight=1 noruler laststatus=2", function() command("set cmdheight=1 noruler laststatus=2") screen:expect{grid=[[ -- cgit From 44f0480a22af8f87f8784dac430416cb9913adea Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 31 Oct 2023 21:33:00 +0100 Subject: refactor(grid): implement rightleftcmd as a post-processing step Previously, 'rightleftcmd' was implemented by having all code which would affect msg_col or output screen cells be conditional on `cmdmsg_rl`. This change removes all that and instead implements rightleft as a mirroring post-processing step. --- test/functional/ui/cmdline_spec.lua | 79 +++++++++++++++++++++++++++++++++++++ 1 file changed, 79 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 497b2e7f4c..188b9ee87b 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -24,6 +24,7 @@ local function new_screen(opt) [7] = {bold = true, foreground = Screen.colors.Brown}, [8] = {background = Screen.colors.LightGrey}, [9] = {bold = true}, + [10] = {background = Screen.colors.Yellow1}; }) return screen end @@ -771,6 +772,84 @@ describe('cmdline redraw', function() :^abc | ]]) end) + + it('with rightleftcmd', function() + command('set rightleft rightleftcmd=search shortmess+=s') + meths.buf_set_lines(0, 0, -1, true, {"let's rock!"}) + screen:expect{grid=[[ + !kcor s'te^l| + {1: ~}| + {1: ~}| + {1: ~}| + | + ]]} + + feed '/' + screen:expect{grid=[[ + !kcor s'tel| + {1: ~}| + {1: ~}| + {1: ~}| + ^ /| + ]]} + + feed "let's" + -- note: cursor looks off but looks alright in real use + -- when rendered as a block so it touches the end of the text + screen:expect{grid=[[ + !kcor {2:s'tel}| + {1: ~}| + {1: ~}| + {1: ~}| + ^ s'tel/| + ]]} + + -- cursor movement + feed "" + screen:expect{grid=[[ + !kcor{2: s'tel}| + {1: ~}| + {1: ~}| + {1: ~}| + ^ s'tel/| + ]]} + + feed "rock" + screen:expect{grid=[[ + !{2:kcor s'tel}| + {1: ~}| + {1: ~}| + {1: ~}| + ^ kcor s'tel/| + ]]} + + feed "" + screen:expect{grid=[[ + !{2:kcor s'tel}| + {1: ~}| + {1: ~}| + {1: ~}| + ^kcor s'tel/| + ]]} + + feed "" + screen:expect{grid=[[ + !{2:kcor s'tel}| + {1: ~}| + {1: ~}| + {1: ~}| + ^ kcor s'tel/| + ]]} + + feed "" + screen:expect{grid=[[ + !{10:kcor s'te^l}| + {1: ~}| + {1: ~}| + {1: ~}| + kcor s'tel/ | + ]]} + end) end) describe('statusline is redrawn on entering cmdline', function() -- cgit