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`.
This commit is contained in:
luukvbaal
2025-06-15 12:55:01 +02:00
committed by GitHub
parent 0d658660c2
commit 5046ef4c8f
7 changed files with 104 additions and 20 deletions

View File

@ -759,9 +759,6 @@ void ui_call_event(char *name, bool fast, Array args)
uint32_t ns_id = ui_event_ns_id;
Object res = nlua_call_ref_ctx(fast, event_cb->cb, name, args, kRetNilBool, NULL, &err);
ui_event_ns_id = 0;
// TODO(bfredl/luukvbaal): should this be documented or reconsidered?
// Why does truthy return from Lua callback mean remote UI should not receive
// the event.
if (LUARET_TRUTHY(res)) {
handled = true;
}