aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_extui/cmdline.lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2025-05-09 12:17:26 +0200
committerGitHub <noreply@github.com>2025-05-09 12:17:26 +0200
commit7e787f6a4f16ddccfc3017e44f9cb9c9d1615dc3 (patch)
tree69f9dd1f4b3f982a86bb5096be7f9424f0b7af7c /runtime/lua/vim/_extui/cmdline.lua
parent3121e02ae04e489fb11b7058f7b7d0da0901dafa (diff)
downloadrneovim-7e787f6a4f16ddccfc3017e44f9cb9c9d1615dc3.tar.gz
rneovim-7e787f6a4f16ddccfc3017e44f9cb9c9d1615dc3.tar.bz2
rneovim-7e787f6a4f16ddccfc3017e44f9cb9c9d1615dc3.zip
fix(extui): route interactive messages to more-window (#33885)
Problem: Extui does not route messages emitted as a result of a typed command to the "more" window. Command message leading shell messages is missing a kind. Messages not routed to 'cmdheight' area after it was 0. Solution: Route messages that were emitted in the same event loop as an entered command to the "more" window. Also append multiple messages in an already open more-window. Assign it the `shell_cmd` kind. Change message position when 'cmdheight' changes from 0.
Diffstat (limited to 'runtime/lua/vim/_extui/cmdline.lua')
-rw-r--r--runtime/lua/vim/_extui/cmdline.lua23
1 files changed, 14 insertions, 9 deletions
diff --git a/runtime/lua/vim/_extui/cmdline.lua b/runtime/lua/vim/_extui/cmdline.lua
index 61785a8a1a..23f6be0872 100644
--- a/runtime/lua/vim/_extui/cmdline.lua
+++ b/runtime/lua/vim/_extui/cmdline.lua
@@ -6,7 +6,7 @@ local M = {
indent = 0, -- Current indent for block event.
prompt = false, -- Whether a prompt is active; messages are placed in the 'prompt' window.
row = 0, -- Current row in the cmdline buffer, > 0 for block events.
- level = 0, -- Current cmdline level, 0 when inactive (otherwise unused).
+ level = -1, -- Current cmdline level, 0 when inactive, -1 one loop iteration after closing.
}
--- Set the 'cmdheight' and cmdline window height. Reposition message windows.
@@ -121,16 +121,21 @@ function M.cmdline_hide(_, abort)
api.nvim_buf_set_lines(ext.bufs.cmd, 0, -1, false, {})
end
- -- Avoid clearing prompt window when it is re-entered before the next event
- -- loop iteration. E.g. when a non-choice confirm button is pressed.
- if M.prompt then
+ local clear = vim.schedule_wrap(function(was_prompt)
+ -- Avoid clearing prompt window when it is re-entered before the next event
+ -- loop iteration. E.g. when a non-choice confirm button is pressed.
+ if was_prompt and not M.prompt then
+ api.nvim_buf_set_lines(ext.bufs.cmd, 0, -1, false, {})
+ api.nvim_win_set_config(ext.wins[ext.tab].prompt, { hide = true })
+ end
+ -- Messages emitted as a result of a typed command are treated specially:
+ -- remember if the cmdline was used this event loop iteration.
+ -- NOTE: Message event callbacks are themselves scheduled, so delay two iterations.
vim.schedule(function()
- if not M.prompt then
- api.nvim_buf_set_lines(ext.bufs.cmd, 0, -1, false, {})
- api.nvim_win_set_config(ext.wins[ext.tab].prompt, { hide = true })
- end
+ M.level = -1
end)
- end
+ end)
+ clear(M.prompt)
M.prompt, M.level, curpos[1], curpos[2] = false, 0, 0, 0
win_config(ext.wins[ext.tab].cmd, true, ext.cmdheight)