aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-27 09:07:30 +0800
committerGitHub <noreply@github.com>2023-04-27 09:07:30 +0800
commit1fc468aed2809a92769fbdfd6c422c2b9b12a233 (patch)
tree1b25227fa25417e6152e71dc2f033da2cf18f4fd
parent3b0df1780e2c8526bda5dead18ee7cc45925caba (diff)
downloadrneovim-1fc468aed2809a92769fbdfd6c422c2b9b12a233.tar.gz
rneovim-1fc468aed2809a92769fbdfd6c422c2b9b12a233.tar.bz2
rneovim-1fc468aed2809a92769fbdfd6c422c2b9b12a233.zip
vim-patch:9.0.1491: wrong scrolling with ls=0 and :botright split (#23333)
Problem: Wrong scrolling with ls=0 and :botright split. Solution: Add statusline before calling frame_new_height(). (closes vim/vim#12299) https://github.com/vim/vim/commit/fbf2071ac9ef08302a1df86c15f3d4ddbe871243
-rw-r--r--src/nvim/window.c28
-rw-r--r--test/functional/legacy/window_cmd_spec.lua29
-rw-r--r--test/old/testdir/test_window_cmd.vim18
3 files changed, 59 insertions, 16 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index a45ceeb611..88d9b95208 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1448,7 +1448,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
frame_fix_width(oldwin);
frame_fix_width(wp);
} else {
- bool is_stl_global = global_stl_height() > 0;
+ const bool is_stl_global = global_stl_height() > 0;
// width and column of new window is same as current window
if (flags & (WSP_TOP | WSP_BOT)) {
wp->w_wincol = 0;
@@ -1464,6 +1464,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
// "new_size" of the current window goes to the new window, use
// one row for the status line
win_new_height(wp, new_size);
+ const int old_status_height = oldwin->w_status_height;
if (before) {
wp->w_hsep_height = is_stl_global ? 1 : 0;
} else {
@@ -1472,15 +1473,19 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
}
if (flags & (WSP_TOP | WSP_BOT)) {
int new_fr_height = curfrp->fr_height - new_size;
-
- if (!((flags & WSP_BOT) && p_ls == 0) && !is_stl_global) {
- new_fr_height -= STATUS_HEIGHT;
- } else if (is_stl_global) {
+ if (is_stl_global) {
if (flags & WSP_BOT) {
frame_add_hsep(curfrp);
} else {
new_fr_height -= 1;
}
+ } else {
+ if (!((flags & WSP_BOT) && p_ls == 0)) {
+ new_fr_height -= STATUS_HEIGHT;
+ }
+ if (flags & WSP_BOT) {
+ frame_add_statusline(curfrp);
+ }
}
frame_new_height(curfrp, new_fr_height, flags & WSP_TOP, false);
} else {
@@ -1489,7 +1494,6 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
if (before) { // new window above current one
wp->w_winrow = oldwin->w_winrow;
-
if (is_stl_global) {
wp->w_status_height = 0;
oldwin->w_winrow += wp->w_height + 1;
@@ -1503,15 +1507,12 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
wp->w_status_height = 0;
} else {
wp->w_winrow = oldwin->w_winrow + oldwin->w_height + STATUS_HEIGHT;
- wp->w_status_height = oldwin->w_status_height;
+ wp->w_status_height = old_status_height;
if (!(flags & WSP_BOT)) {
oldwin->w_status_height = STATUS_HEIGHT;
}
}
}
- if ((flags & WSP_BOT) && !is_stl_global) {
- frame_add_statusline(curfrp);
- }
frame_fix_height(wp);
frame_fix_height(oldwin);
}
@@ -3590,12 +3591,7 @@ static void frame_add_statusline(frame_T *frp)
{
if (frp->fr_layout == FR_LEAF) {
win_T *wp = frp->fr_win;
- if (wp->w_status_height == 0) {
- if (wp->w_height - STATUS_HEIGHT >= 0) { // don't make it negative
- wp->w_height -= STATUS_HEIGHT;
- }
- wp->w_status_height = STATUS_HEIGHT;
- }
+ wp->w_status_height = STATUS_HEIGHT;
} else if (frp->fr_layout == FR_ROW) {
// Handle all the frames in the row.
FOR_ALL_FRAMES(frp, frp->fr_child) {
diff --git a/test/functional/legacy/window_cmd_spec.lua b/test/functional/legacy/window_cmd_spec.lua
index c7b5878b92..3a51f7a23f 100644
--- a/test/functional/legacy/window_cmd_spec.lua
+++ b/test/functional/legacy/window_cmd_spec.lua
@@ -3,8 +3,37 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local exec = helpers.exec
local exec_lua = helpers.exec_lua
+local command = helpers.command
local feed = helpers.feed
+-- oldtest: Test_window_cmd_ls0_split_scrolling()
+it('scrolling with laststatus=0 and :botright split', function()
+ clear('--cmd', 'set ruler')
+ local screen = Screen.new(40, 10)
+ screen:set_default_attr_ids({
+ [1] = {reverse = true}, -- StatusLineNC
+ })
+ screen:attach()
+ exec([[
+ set laststatus=0
+ call setline(1, range(1, 100))
+ normal! G
+ ]])
+ command('botright split')
+ screen:expect([[
+ 97 |
+ 98 |
+ 99 |
+ 100 |
+ {1:[No Name] [+] 100,1 Bot}|
+ 97 |
+ 98 |
+ 99 |
+ ^100 |
+ 100,1 Bot |
+ ]])
+end)
+
describe('splitkeep', function()
local screen
diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim
index 9320d67498..f938203736 100644
--- a/test/old/testdir/test_window_cmd.vim
+++ b/test/old/testdir/test_window_cmd.vim
@@ -19,6 +19,24 @@ func Test_window_cmd_ls0_with_split()
set ls&vim
endfunc
+func Test_window_cmd_ls0_split_scrolling()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ set laststatus=0
+ call setline(1, range(1, 100))
+ normal! G
+ END
+ call writefile(lines, 'XTestLs0SplitScrolling', 'D')
+ let buf = RunVimInTerminal('-S XTestLs0SplitScrolling', #{rows: 10})
+
+ call term_sendkeys(buf, ":botright split\<CR>")
+ call WaitForAssert({-> assert_match('Bot$', term_getline(buf, 5))})
+ call assert_equal('100', term_getline(buf, 4))
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_window_cmd_cmdwin_with_vsp()
let efmt = 'Expected 0 but got %d (in ls=%d, %s window)'
for v in range(0, 2)