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.
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index f913fb5..9994cb6 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -11095,6 +11095,11 @@
{
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 @@
/*
* 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 @@
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 @@
/* 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 @@
|| 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