summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-21 17:13:14 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-21 17:13:14 +0200
commitb8bd2e6ebab03baf2672067067a599df69a278c0 (patch)
treec0a490909a31bc6ab7ede44e1c490ef289f949e3 /src/ex_cmds.c
parent489d60996deb5e7c1a3b4633412d54632e6def42 (diff)
patch 8.2.3363: when :edit reuses the current buffer the alternate file is setv8.2.3363
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 #8783)
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index d30db91952..021296d38c 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2648,6 +2648,8 @@ do_ecmd(
*/
if (other_file)
{
+ int prev_alt_fnum = curwin->w_alt_fnum;
+
if (!(flags & (ECMD_ADDBUF | ECMD_ALTBUF)))
{
if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
@@ -2691,6 +2693,10 @@ do_ecmd(
}
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;