summaryrefslogtreecommitdiffstats
path: root/src/ex_docmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-03-09 21:33:34 +0100
committerBram Moolenaar <Bram@vim.org>2018-03-09 21:33:34 +0100
commit4d8bac8bf593ff087517ff79090c2d224325aae6 (patch)
tree51e277a9012731df3a3dc362af5c5db39991485a /src/ex_docmd.c
parent20586cb4f4d516a60b96cc02a94b810fea8b8cdb (diff)
patch 8.0.1592: terminal windows in a session are not properly restoredv8.0.1592
Problem: Terminal windows in a session are not properly restored. Solution: Add "terminal" in 'sessionoptions'. When possible restore the command running in a terminal.
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r--src/ex_docmd.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index f913fb5278..9994cb64ea 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -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