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().
This commit is contained in:
jyn
2025-04-08 08:54:32 -04:00
committed by GitHub
parent 5b1561bb71
commit 3647b821ea
3 changed files with 56 additions and 14 deletions

View File

@@ -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;
}
}