0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.0.1592: terminal windows in a session are not properly restored

Problem:    Terminal windows in a session are not properly restored.
Solution:   Add "terminal" in 'sessionoptions'.  When possible restore the
            command running in a terminal.
This commit is contained in:
Bram Moolenaar
2018-03-09 21:33:34 +01:00
parent 20586cb4f4
commit 4d8bac8bf5
12 changed files with 274 additions and 20 deletions

View File

@@ -11095,6 +11095,11 @@ makeopens(
{
if (!(only_save_windows && buf->b_nwindows == 0)
&& !(buf->b_help && !(ssop_flags & SSOP_HELP))
#ifdef FEAT_TERMINAL
/* skip terminal buffers: finished ones are not useful, others
* will be resurrected and result in a new buffer */
&& !bt_terminal(buf)
#endif
&& buf->b_fname != NULL
&& buf->b_p_bl)
{
@@ -11305,7 +11310,8 @@ makeopens(
/*
* Wipe out an empty unnamed buffer we started in.
*/
if (put_line(fd, "if exists('s:wipebuf')") == FAIL)
if (put_line(fd, "if exists('s:wipebuf') && s:wipebuf != bufnr('%')")
== FAIL)
return FAIL;
if (put_line(fd, " silent exe 'bwipe ' . s:wipebuf") == FAIL)
return FAIL;
@@ -11465,6 +11471,12 @@ ses_do_frame(frame_T *fr)
static int
ses_do_win(win_T *wp)
{
#ifdef FEAT_TERMINAL
if (bt_terminal(wp->w_buffer))
return !term_is_finished(wp->w_buffer)
&& (ssop_flags & SSOP_TERMINAL)
&& term_should_restore(wp->w_buffer);
#endif
if (wp->w_buffer->b_fname == NULL
#ifdef FEAT_QUICKFIX
/* When 'buftype' is "nofile" can't restore the window contents. */
@@ -11530,13 +11542,21 @@ put_view(
/* Edit the file. Skip this when ":next" already did it. */
if (add_edit && (!did_next || wp->w_arg_idx_invalid))
{
# ifdef FEAT_TERMINAL
if (bt_terminal(wp->w_buffer))
{
if (term_write_session(fd, wp) == FAIL)
return FAIL;
}
else
# endif
/*
* Load the file.
*/
if (wp->w_buffer->b_ffname != NULL
#ifdef FEAT_QUICKFIX
# ifdef FEAT_QUICKFIX
&& !bt_nofile(wp->w_buffer)
#endif
# endif
)
{
/*
@@ -11554,8 +11574,7 @@ put_view(
|| fputs(" | else | edit ", fd) < 0
|| ses_fname(fd, wp->w_buffer, flagp, FALSE) == FAIL
|| fputs(" | endif", fd) < 0
||
put_eol(fd) == FAIL)
|| put_eol(fd) == FAIL)
return FAIL;
}
else