diff options
author | jyn <github@jyn.dev> | 2025-04-08 08:54:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-08 05:54:32 -0700 |
commit | 3647b821ea69ea095ccc4bf8c265df474333a5d5 (patch) | |
tree | 626ae9dfd2fda5fb8fb150a1ea2f72926240c002 /src/nvim/ex_cmds2.c | |
parent | 5b1561bb717eae8781ff62646c675c7e842e4444 (diff) | |
download | rneovim-3647b821ea69ea095ccc4bf8c265df474333a5d5.tar.gz rneovim-3647b821ea69ea095ccc4bf8c265df474333a5d5.tar.bz2 rneovim-3647b821ea69ea095ccc4bf8c265df474333a5d5.zip |
fix(editor): respect [+cmd] when executing :drop #33339
Problem:
Normally, `:drop +41 foo.txt` will open foo.txt with the cursor on line
41. But if foo.txt is already open, it instead is a no-op, even if the
cursor is on a different line.
Steps to reproduce:
nvim --clean foo.txt
:drop +30 foo.txt
Solution:
Handle +cmd in ex_drop().
Diffstat (limited to 'src/nvim/ex_cmds2.c')
-rw-r--r-- | src/nvim/ex_cmds2.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 5bd79719e7..18206cb3c1 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -888,6 +888,17 @@ void ex_drop(exarg_T *eap) if (curbuf->b_ml.ml_flags & ML_EMPTY) { ex_rewind(eap); } + + // execute [+cmd] + if (eap->do_ecmd_cmd) { + bool did_set_swapcommand = set_swapcommand(eap->do_ecmd_cmd, 0); + do_cmdline(eap->do_ecmd_cmd, NULL, NULL, DOCMD_VERBOSE); + if (did_set_swapcommand) { + set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); + } + } + + // no need to execute [++opts] - they only apply for newly loaded buffers. return; } } |