aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2022-07-31 17:19:17 +0900
committerzeertzjq <zeertzjq@outlook.com>2022-07-31 17:15:36 +0800
commit63244f68e70f233b4175ce0018a58932f075d4c5 (patch)
tree310e98dc31665bd174911bc480f973a0005456f2 /src/nvim/ex_getln.c
parent81a1d26c3eee816abaa3d0e611a8b1a0e473d3a1 (diff)
downloadrneovim-63244f68e70f233b4175ce0018a58932f075d4c5.tar.gz
rneovim-63244f68e70f233b4175ce0018a58932f075d4c5.tar.bz2
rneovim-63244f68e70f233b4175ce0018a58932f075d4c5.zip
vim-patch:9.0.0115: when 'cmdheight' is zero pressing ':' may scroll a window
Problem: When 'cmdheight' is zero pressing ':' may scroll a window. Solution: Add the made_cmdheight_nonzero flag and set 'scrolloff' to zero. https://github.com/vim/vim/commit/6747cf1671bd41cddee77c65b3f9a70509f968db
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r--src/nvim/ex_getln.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index be7e7377ed..a6e8ad433f 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -692,9 +692,19 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init
const bool cmdheight0 = !ui_has_messages();
if (cmdheight0) {
- // If cmdheight is 0, cmdheight must be set to 1 when we enter command line.
+ const long save_so = lastwin->w_p_so;
+
+ // If cmdheight is 0, cmdheight must be set to 1 when we enter the
+ // command line. Set "made_cmdheight_nonzero" and reset 'scrolloff' to
+ // avoid scrolling the last window.
+ made_cmdheight_nonzero = true;
+
+ lastwin->w_p_so = 0;
set_option_value("ch", 1L, NULL, 0);
update_screen(VALID); // redraw the screen NOW
+
+ made_cmdheight_nonzero = false;
+ lastwin->w_p_so = save_so;
}
// can be invoked recursively, identify each level
@@ -991,10 +1001,14 @@ theend:
}
if (cmdheight0) {
+ made_cmdheight_nonzero = true;
+
// Restore cmdheight
set_option_value("ch", 0L, NULL, 0);
// Redraw is needed for command line completion
redraw_all_later(CLEAR);
+
+ made_cmdheight_nonzero = false;
}
return p;