diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 29115b5716..2651584a36 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -8633,6 +8633,7 @@ local options = { }, { abbreviation = 'spk', + cb = 'did_set_splitkeep', defaults = 'cursor', values = { 'cursor', 'screen', 'topline' }, desc = [=[ diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 274fbb653c..74301ecab2 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -1831,6 +1831,14 @@ const char *did_set_spellsuggest(optset_T *args FUNC_ATTR_UNUSED) return NULL; } +const char *did_set_splitkeep(optset_T *args FUNC_ATTR_UNUSED) +{ + FOR_ALL_TAB_WINDOWS(tp, wp) { + wp->w_prev_height = wp->w_height; + } + return did_set_str_generic(args); +} + /// The 'statuscolumn' option is changed. const char *did_set_statuscolumn(optset_T *args) { diff --git a/src/nvim/window.c b/src/nvim/window.c index 40f471a9fb..7877dde592 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -7139,6 +7139,7 @@ void command_height(void) if (p_ch < old_p_ch && command_frame_height && frp != NULL) { frame_add_height(frp, (int)(old_p_ch - p_ch)); } + win_fix_scroll(true); // Recompute window positions. win_comp_pos(); diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim index 8d77d3851f..4f4aec4ffb 100644 --- a/test/old/testdir/test_window_cmd.vim +++ b/test/old/testdir/test_window_cmd.vim @@ -1944,6 +1944,16 @@ func Test_splitkeep_screen_cursor_pos() set splitkeep& endfunc +func Test_splitkeep_cmdheight() + set splitkeep=screen + call setline(1, range(&lines)) + norm! G + set cmdheight=2 + call assert_equal(&lines - 1, line('.')) + %bwipeout! + set splitkeep& cmdheight& +endfunc + func Test_splitkeep_cursor() CheckScreendump let lines =<< trim END