From 46eabe1ac1f70d0d7b199cb7e505b275b2f01bff Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sun, 16 Oct 2022 22:34:14 +0200 Subject: fix: 'scroll' is not set correctly for floats with 'splitkeep' vim-patch:9.0.0780: 'scroll' value computed in unexpected location Problem: 'scroll' value computed in unexpected location. Solution: Compute 'scroll' when the window height is changed. (Luuk van Baal, closes vim/vim#11387) https://github.com/vim/vim/commit/a1a46da87d91cfbf46866627b3e66a757145e8c3 --- src/nvim/window.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nvim/window.c b/src/nvim/window.c index 002d95ac2a..7c246191a5 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -6119,7 +6119,6 @@ void win_fix_scroll(int resize) invalidate_botline_win(wp); validate_botline(wp); } - win_comp_scroll(wp); wp->w_prev_height = wp->w_height; wp->w_prev_winrow = wp->w_winrow; } @@ -6292,7 +6291,6 @@ void scroll_to_fraction(win_T *wp, int prev_height) wp->w_prev_fraction_row = wp->w_wrow; } - win_comp_scroll(wp); redraw_later(wp, UPD_SOME_VALID); wp->w_redr_status = true; invalidate_botline_win(wp); @@ -6327,6 +6325,7 @@ void win_set_inner_size(win_T *wp, bool valid_cursor) } wp->w_skipcol = 0; wp->w_height_inner = height; + win_comp_scroll(wp); // There is no point in adjusting the scroll position when exiting. Some // values might be invalid. -- cgit From 14a84ec169ca8ca29a80237e82f2bb8e15a28365 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 17 Oct 2022 21:39:49 +0800 Subject: test: add a test for #20684 --- test/functional/ui/float_spec.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 1a9a13f7d4..9ef36cf5ae 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -430,6 +430,13 @@ describe('float window', function() assert_alive() end) + it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function() + meths.set_option('splitkeep', 'screen') + local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10} + local float_win = meths.open_win(0, true, float_opts) + eq(5, meths.win_get_option(float_win, 'scroll')) + end) + describe('with only one tabpage,', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} local old_buf, old_win -- cgit