From 3b562535c323292637a53d36d9bd341feea2f2c6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 12 Oct 2022 07:47:28 +0800 Subject: [PATCH 1/2] vim-patch:8.2.4523: when gvim is started maximized the 'window' option isn't set Problem: When gvim is started maximized the 'window' option isn't set properly. (Christian J. Robinson) Solution: Check if 'windows' was already set or not. (Ken Takata, closes vim/vim#9904) https://github.com/vim/vim/commit/6ca883dd8a585a85acdf9303b434211ea91872a7 --- src/nvim/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/window.c b/src/nvim/window.c index d7ca718c68..d99d22af12 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5226,7 +5226,7 @@ void win_new_screensize(void) if (old_Rows != Rows) { // If 'window' uses the whole screen, keep it using that. // Don't change it when set with "-w size" on the command line. - if (p_window == old_Rows - 1 || (old_Rows == 0 && p_window == 0)) { + if (p_window == old_Rows - 1 || (old_Rows == 0 && !option_was_set("window"))) { p_window = Rows - 1; } old_Rows = Rows; From 9115f665559777d1016af20f094c51e0eeff444c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 12 Oct 2022 11:35:47 +0800 Subject: [PATCH 2/2] test: add a test for #20605 --- test/functional/ui/screen_basic_spec.lua | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 58c8238c35..f111aa2513 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -1027,3 +1027,36 @@ describe('Screen default colors', function() end} end) end) + +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(99, meths.win_get_height(0)) + feed('1000o') + eq(903, funcs.line('w0')) + feed('') + eq(806, funcs.line('w0')) + feed('') + eq(709, funcs.line('w0')) + feed('') + eq(806, funcs.line('w0')) + feed('') + 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(49, meths.win_get_height(0)) + eq(953, funcs.line('w0')) + feed('') + eq(906, funcs.line('w0')) + feed('') + eq(859, funcs.line('w0')) + feed('') + eq(906, funcs.line('w0')) + feed('') + eq(953, funcs.line('w0')) +end)