summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-11-07 18:41:10 +0100
committerBram Moolenaar <Bram@vim.org>2020-11-07 18:41:10 +0100
commit59d8e56e048eb5d384649284fb35363931fc3697 (patch)
tree3941971859628440195075acf6104cac9ef43821 /src/ex_cmds.c
parentcbcd9cbd77acc8cc97c0d44683d96c01d3dd0fa7 (diff)
patch 8.2.1967: the session file does not restore the alternate filev8.2.1967
Problem: The session file does not restore the alternate file. Solution: Add ":balt". Works like ":badd" and also sets the buffer as the alternate file. Use it in the session file. (closes #7269, closes #6714)
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 185033f1d5..aa9fe9b0a0 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2459,6 +2459,7 @@ theend:
* ECMD_OLDBUF: use existing buffer if it exists
* ECMD_FORCEIT: ! used for Ex command
* ECMD_ADDBUF: don't edit, just add to buffer list
+ * ECMD_ALTBUF: like ECMD_ADDBUF and also set the alternate file
* oldwin: Should be "curwin" when editing a new buffer in the current
* window, NULL when splitting the window first. When not NULL info
* of the previous buffer for "oldwin" is stored.
@@ -2555,7 +2556,8 @@ do_ecmd(
fname_case(sfname, 0); // set correct case for sfname
#endif
- if ((flags & ECMD_ADDBUF) && (ffname == NULL || *ffname == NUL))
+ if ((flags & (ECMD_ADDBUF | ECMD_ALTBUF))
+ && (ffname == NULL || *ffname == NUL))
goto theend;
if (ffname == NULL)
@@ -2584,7 +2586,7 @@ do_ecmd(
*/
if ( ((!other_file && !(flags & ECMD_OLDBUF))
|| (curbuf->b_nwindows == 1
- && !(flags & (ECMD_HIDE | ECMD_ADDBUF))))
+ && !(flags & (ECMD_HIDE | ECMD_ADDBUF | ECMD_ALTBUF))))
&& check_changed(curbuf, (p_awa ? CCGD_AW : 0)
| (other_file ? 0 : CCGD_MULTWIN)
| ((flags & ECMD_FORCEIT) ? CCGD_FORCEIT : 0)
@@ -2633,7 +2635,7 @@ do_ecmd(
*/
if (other_file)
{
- if (!(flags & ECMD_ADDBUF))
+ if (!(flags & (ECMD_ADDBUF | ECMD_ALTBUF)))
{
if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
curwin->w_alt_fnum = curbuf->b_fnum;
@@ -2645,11 +2647,12 @@ do_ecmd(
buf = buflist_findnr(fnum);
else
{
- if (flags & ECMD_ADDBUF)
+ if (flags & (ECMD_ADDBUF | ECMD_ALTBUF))
{
// Default the line number to zero to avoid that a wininfo item
// is added for the current window.
linenr_T tlnum = 0;
+ buf_T *newbuf;
if (command != NULL)
{
@@ -2657,10 +2660,12 @@ do_ecmd(
if (tlnum <= 0)
tlnum = 1L;
}
- // Add BLN_NOCURWIN to avoid a new wininfo items is assocated
+ // Add BLN_NOCURWIN to avoid a new wininfo items are assocated
// with the current window.
- (void)buflist_new(ffname, sfname, tlnum,
+ newbuf = buflist_new(ffname, sfname, tlnum,
BLN_LISTED | BLN_NOCURWIN);
+ if (newbuf != NULL && (flags & ECMD_ALTBUF))
+ curwin->w_alt_fnum = newbuf->b_fnum;
goto theend;
}
buf = buflist_new(ffname, sfname, 0L,
@@ -2818,7 +2823,7 @@ do_ecmd(
}
else // !other_file
{
- if ((flags & ECMD_ADDBUF) || check_fname() == FAIL)
+ if ((flags & (ECMD_ADDBUF | ECMD_ALTBUF)) || check_fname() == FAIL)
goto theend;
oldbuf = (flags & ECMD_OLDBUF);