From 197827321a39168dbaa143c9f7b4f5db668f893c Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Mon, 1 May 2023 20:08:25 +0200 Subject: [PATCH] fix(tui): grid_clear properly clears the screen Problem: When setting a shell size smaller than the containing terminal window through `:winsize` or `:set lines/columns` the screen is not properly cleared. Solution: Clear the tui dimensions rather than the grid dimensions. --- src/nvim/tui/tui.c | 2 +- test/functional/terminal/api_spec.lua | 8 ++++---- test/functional/terminal/tui_spec.lua | 13 +++++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 975ad375a0..0d661d2b58 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -977,7 +977,7 @@ void tui_grid_clear(TUIData *tui, Integer g) UGrid *grid = &tui->grid; ugrid_clear(grid); kv_size(tui->invalid_regions) = 0; - clear_region(tui, 0, grid->height, 0, grid->width, 0); + clear_region(tui, 0, tui->height, 0, tui->width, 0); } void tui_grid_cursor_goto(TUIData *tui, Integer grid, Integer row, Integer col) diff --git a/test/functional/terminal/api_spec.lua b/test/functional/terminal/api_spec.lua index 724791343d..93641fc576 100644 --- a/test/functional/terminal/api_spec.lua +++ b/test/functional/terminal/api_spec.lua @@ -66,10 +66,10 @@ describe('api', function() screen:expect([[ [tui] insert-mode | - [socket 1] this is more t{4: }| - han 25 columns {4: }| - [socket 2] input{1: } {4: }| - {4:~ }| + [socket 1] this is more t | + han 25 columns | + [socket 2] input{1: } | + {4:~ } | {3:-- INSERT --} | {3:-- TERMINAL --} | ]]) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 069fbad803..5fd3467949 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -2422,6 +2422,19 @@ describe("TUI as a client", function() {3:-- TERMINAL --} | ]]} + -- grid smaller than containing terminal window is cleared properly + feed_data(":call setline(1,['a'->repeat(&columns)]->repeat(&lines))\n") + feed_data("0:set lines=2\n") + screen_server:expect{grid=[[ + {1:a}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {5:[No Name] [+] }| + | + | + | + | + {3:-- TERMINAL --} | + ]]} + feed_data(":q!\n") server_super:close()