aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-04-30 02:23:28 +0200
committerJustin M. Keyes <justinkz@gmail.com>2026-04-30 19:19:42 +0200
commit7c4845ff463b63324c4d45f03fdd58b7f70e54ba (patch)
tree5b013bf2aadba947952d3828c227f44138127cb2 /src/nvim/lua/executor.c
parent18d7dd485be57b85308d1e47ab44ce21e7a80be3 (diff)
downloadrneovim-7c4845ff463b63324c4d45f03fdd58b7f70e54ba.tar.gz
rneovim-7c4845ff463b63324c4d45f03fdd58b7f70e54ba.tar.bz2
rneovim-7c4845ff463b63324c4d45f03fdd58b7f70e54ba.zip
fix(ui): z=, tselect with async vim.ui.select
Problem: After 55ceb31, z= and tselect don't work if `vim.ui.select` is an async provider (especially terminal buffers). Solution: Drop the `vim.wait()` approach, use an async approach. fix #39506
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r--src/nvim/lua/executor.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 468c706014..7078a0650e 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -34,6 +34,7 @@
#include "nvim/event/time.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
#include "nvim/garray.h"
#include "nvim/garray_defs.h"
@@ -180,6 +181,25 @@ static void nlua_push_cmdmod(lua_State *lstate, const cmdmod_T *cmod)
/// Pushes common exarg_T fields (bang, line1, line2, …) onto a table at the top of the stack.
static void nlua_push_eap(lua_State *lstate, exarg_T *eap, const cmdmod_T *cmod)
{
+ // Canonical name (for builtin cmds); for usercmds `nlua_do_ucmd` sets "name" to the user-defined name.
+ if (!IS_USER_CMDIDX(eap->cmdidx) && eap->cmdidx < CMD_SIZE) {
+ lua_pushstring(lstate, get_command_name(NULL, eap->cmdidx));
+ lua_setfield(lstate, -2, "name");
+ }
+
+ // Modifier string (e.g. ":vert silent"). Same content as `nvim_parse_cmd().mods`.
+ // Useful when forwarding the command verbatim, e.g. `feedkeys('<Cmd>'..eap.mods..' …<CR>')`.
+ //
+ // The size is chosen empirically to hold every modifier with room to spare; bump if more are added.
+ char mods_buf[200] = { 0 };
+ uc_mods(mods_buf, cmod, false);
+ lua_pushstring(lstate, mods_buf);
+ lua_setfield(lstate, -2, "mods");
+
+ // Structured form of `mods`.
+ nlua_push_cmdmod(lstate, cmod);
+ lua_setfield(lstate, -2, "smods");
+
lua_pushstring(lstate, eap->arg);
lua_setfield(lstate, -2, "args");
@@ -211,9 +231,6 @@ static void nlua_push_eap(lua_State *lstate, exarg_T *eap, const cmdmod_T *cmod)
}
lua_setfield(lstate, -2, "fargs");
}
-
- nlua_push_cmdmod(lstate, cmod);
- lua_setfield(lstate, -2, "smods");
}
#if __has_feature(address_sanitizer)
@@ -2371,16 +2388,6 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
lua_pushstring(lstate, nargs);
lua_setfield(lstate, -2, "nargs");
- // User commands also get a string "mods" field (in addition to "smods" from nlua_push_eap).
- //
- // The size of this buffer is chosen empirically to be large enough to hold
- // every possible modifier (with room to spare). If the list of possible
- // modifiers grows this may need to be updated.
- char buf[200] = { 0 };
- uc_mods(buf, &cmdmod, false);
- lua_pushstring(lstate, buf);
- lua_setfield(lstate, -2, "mods");
-
if (preview) {
lua_pushinteger(lstate, cmdpreview_get_ns());