aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-11 20:55:26 +0800
committerGitHub <noreply@github.com>2022-07-11 20:55:26 +0800
commit5c3bbb67e7c59b2fa18e37fdd9845a0e7e3381db (patch)
tree1e390cc6bbfdbc4bf439a792e6e708c5708debb8 /src/nvim/ex_cmds.c
parentac10c0f4184a04c82b8e039c546ab32f4a629e30 (diff)
downloadrneovim-5c3bbb67e7c59b2fa18e37fdd9845a0e7e3381db.tar.gz
rneovim-5c3bbb67e7c59b2fa18e37fdd9845a0e7e3381db.tar.bz2
rneovim-5c3bbb67e7c59b2fa18e37fdd9845a0e7e3381db.zip
vim-patch:8.2.3363: when :edit reuses the current buffer the alternate file is set (#19306)
Problem: When :edit reuses the current buffer the alternate file is set to the same buffer. Solution: Only set the alternate file when not reusing the buffer. (closes vim/vim#8783) https://github.com/vim/vim/commit/b8bd2e6ebab03baf2672067067a599df69a278c0 Cherry-pick Test_cmdline_expand_special() from patches 8.2.{0243,2873}. Move Test_cmd_backtick() to the right place.
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r--src/nvim/ex_cmds.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index f97caf0703..1955a0b3d0 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -2415,6 +2415,8 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
* Otherwise we re-use the current buffer.
*/
if (other_file) {
+ const int prev_alt_fnum = curwin->w_alt_fnum;
+
if (!(flags & (ECMD_ADDBUF | ECMD_ALTBUF))) {
if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
curwin->w_alt_fnum = curbuf->b_fnum;
@@ -2458,6 +2460,10 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
if (buf == NULL) {
goto theend;
}
+ if (curwin->w_alt_fnum == buf->b_fnum && prev_alt_fnum != 0) {
+ // reusing the buffer, keep the old alternate file
+ curwin->w_alt_fnum = prev_alt_fnum;
+ }
if (buf->b_ml.ml_mfp == NULL) {
// No memfile yet.
oldbuf = false;