summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
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;