aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_extui.lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2025-06-15 12:55:01 +0200
committerGitHub <noreply@github.com>2025-06-15 12:55:01 +0200
commit5046ef4c8f8d738d90b220cf9a2e2a692bd266ba (patch)
treecad65e70c1815766cf515f12005ece96b69860f2 /runtime/lua/vim/_extui.lua
parent0d658660c29e920e74c4dade3819d80dccad0dde (diff)
downloadrneovim-5046ef4c8f8d738d90b220cf9a2e2a692bd266ba.tar.gz
rneovim-5046ef4c8f8d738d90b220cf9a2e2a692bd266ba.tar.bz2
rneovim-5046ef4c8f8d738d90b220cf9a2e2a692bd266ba.zip
fix(extui): clear cmdline buffer for first message (#34490)
Problem: Cmdline buffer is not cleared for a new message (since c973c7ae), resulting in an incorrect spill indicator. When the cmdline buffer is cleared, "msg_row" is not invalidated, resulting in an error. The extui module is untested. Return value of `vim.ui_attach()->callback` is undocumented. Solution: Clear the cmdline buffer for the first message in an event loop iteration. Ensure msg_row passed as end_row does not exceed buffer length. Add `messages_spec2.lua` to test the extui module, keeping in mind that test coverage will greatly increase if this UI is made the default. As such, only tests for specific extui functionality unlikely to be covered by tests leveraging the current message grid. Document the return value of `vim.ui_attach()->callback`, it seems to make sense, and is also used to suppress remote UI events in `messages_spec2.lua`.
Diffstat (limited to 'runtime/lua/vim/_extui.lua')
-rw-r--r--runtime/lua/vim/_extui.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/runtime/lua/vim/_extui.lua b/runtime/lua/vim/_extui.lua
index d27d665c15..1b9d81b091 100644
--- a/runtime/lua/vim/_extui.lua
+++ b/runtime/lua/vim/_extui.lua
@@ -40,9 +40,6 @@ local M = {}
local function ui_callback(event, ...)
local handler = ext.msg[event] or ext.cmd[event]
- if not handler then
- return
- end
ext.tab_check_wins()
handler(...)
api.nvim__redraw({
@@ -59,6 +56,9 @@ function M.enable(opts)
if opts.msg then
vim.validate('opts.msg.pos', opts.msg.pos, 'nil', true, 'nil: "pos" moved to opts.target')
vim.validate('opts.msg.box', opts.msg.box, 'nil', true, 'nil: "timeout" moved to opts.msg')
+ vim.validate('opts.msg.target', opts.msg.target, function(tar)
+ return tar == 'cmd' or tar == 'msg'
+ end, "'cmd'|'msg'")
end
ext.cfg = vim.tbl_deep_extend('keep', opts, ext.cfg)
@@ -76,11 +76,15 @@ function M.enable(opts)
end
vim.ui_attach(ext.ns, { ext_messages = true, set_cmdheight = false }, function(event, ...)
+ if not (ext.msg[event] or ext.cmd[event]) then
+ return
+ end
if vim.in_fast_event() then
scheduled_ui_callback(event, ...)
else
ui_callback(event, ...)
end
+ return true
end)
-- Use MsgArea and hide search highlighting in the cmdline window.