forked from aniani/vim
patch 8.2.1967: the session file does not restore the alternate file
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)
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user