aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-11-24 10:44:19 +0800
committerGitHub <noreply@github.com>2023-11-24 10:44:19 +0800
commit55dbf5c3798cde8f9bfd36cd17dce636f6f6ea08 (patch)
treef828f487fc40f2d4904cfb64576eaa0656a00653
parenta8a93e517f9eb988ee86170d9a77382637dd24a3 (diff)
downloadrneovim-55dbf5c3798cde8f9bfd36cd17dce636f6f6ea08.tar.gz
rneovim-55dbf5c3798cde8f9bfd36cd17dce636f6f6ea08.tar.bz2
rneovim-55dbf5c3798cde8f9bfd36cd17dce636f6f6ea08.zip
fix(messages): validate msg_grid before using msg_grid_pos (#26189)
-rw-r--r--src/nvim/message.c9
-rw-r--r--test/functional/ui/messages_spec.lua13
2 files changed, 19 insertions, 3 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 2ff0172ac4..2ba6355528 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -2990,10 +2990,13 @@ void msg_clr_eos_force(void)
int msg_startcol = (cmdmsg_rl) ? 0 : msg_col;
int msg_endcol = (cmdmsg_rl) ? Columns - msg_col : Columns;
+ // TODO(bfredl): ugly, this state should already been validated at this
+ // point. But msg_clr_eos() is called in a lot of places.
if (msg_grid.chars && msg_row < msg_grid_pos) {
- // TODO(bfredl): ugly, this state should already been validated at this
- // point. But msg_clr_eos() is called in a lot of places.
- msg_row = msg_grid_pos;
+ msg_grid_validate();
+ if (msg_row < msg_grid_pos) {
+ msg_row = msg_grid_pos;
+ }
}
grid_fill(&msg_grid_adj, msg_row, msg_row + 1, msg_startcol, msg_endcol,
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index a4f13aebc2..1d11a12af4 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -1402,6 +1402,19 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
]])
eq(1, meths.get_option_value('cmdheight', {}))
end)
+
+ it('using nvim_echo in VimResized does not cause hit-enter prompt #26139', function()
+ command([[au VimResized * lua vim.api.nvim_echo({ { '123456' } }, true, {})]])
+ screen:try_resize(60, 5)
+ screen:expect([[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ eq({ mode = 'n', blocking = false }, meths.get_mode())
+ end)
end)
it('calling screenstring() after redrawing between messages without UI #20999', function()