aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-06-28 04:51:55 -0700
committerGitHub <noreply@github.com>2023-06-28 04:51:55 -0700
commite0453d7f5743ad2f515deea76e363d11a7e1fa96 (patch)
tree72953f5e23a89cfb6f5a96831ab2fe5dc0273534 /src
parent42f9573e5da64d6eb8e0dd9ccfefadb68773202c (diff)
downloadrneovim-e0453d7f5743ad2f515deea76e363d11a7e1fa96.tar.gz
rneovim-e0453d7f5743ad2f515deea76e363d11a7e1fa96.tar.bz2
rneovim-e0453d7f5743ad2f515deea76e363d11a7e1fa96.zip
fix(api): nvim_cmd{cmd="win_getid"} parsed as :winsize #24181
Problem: `:lua vim.cmd.win_getid(30,10)` is interpreted as `:win[size] 30 10`. User intention was to call `vim.fn.win_getid(30,10)`. Solution: Check that the `cmd` actually matches the resolved command.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/README.md8
-rw-r--r--src/nvim/api/command.c6
2 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/README.md b/src/nvim/README.md
index 75155fb9c6..0de0fb9a3f 100644
--- a/src/nvim/README.md
+++ b/src/nvim/README.md
@@ -208,15 +208,11 @@ To debug the main process, you can debug the nvim binary with the `--headless`
flag which does not launch the TUI and will allow you to set breakpoints in code
not related to TUI rendering like so:
-```
-lldb -- ./build/bin/nvim --headless --listen ~/.cache/nvim/debug-server.pipe
-```
+ lldb -- ./build/bin/nvim --headless --listen ~/.cache/nvim/debug-server.pipe
You can then attach to the headless process to interact with the editor like so:
-```
-./build/bin/nvim --remote-ui --server ~/.cache/nvim/debug-server.pipe
-```
+ ./build/bin/nvim --remote-ui --server ~/.cache/nvim/debug-server.pipe
Conversely for debugging TUI rendering, you can start a headless process and
debug the remote-ui process multiple times without losing editor state.
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index eba209b424..3157132256 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -393,6 +393,12 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
VALIDATE(!is_cmd_ni(ea.cmdidx), "Command not implemented: %s", cmdname, {
goto end;
});
+ const char *fullname = IS_USER_CMDIDX(ea.cmdidx)
+ ? get_user_command_name(ea.useridx, ea.cmdidx)
+ : get_command_name(NULL, ea.cmdidx);
+ VALIDATE(strncmp(fullname, cmdname, strlen(cmdname)) == 0, "Invalid command: \"%s\"", cmdname, {
+ goto end;
+ });
// Get the command flags so that we can know what type of arguments the command uses.
// Not required for a user command since `find_ex_command` already deals with it in that case.