diff src/buffer.c @ 11917:00836eb177cb v8.0.0838

patch 8.0.0838: buffer hangs around whem terminal window is closed commit https://github.com/vim/vim/commit/94053a51255121713f51c122eb0dbb46c120e6d4 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 1 21:44:33 2017 +0200 patch 8.0.0838: buffer hangs around whem terminal window is closed Problem: Buffer hangs around whem terminal window is closed. Solution: When the job has ended wipe out a terminal buffer when the window is closed.
author Christian Brabandt <cb@256bit.org>
date Tue, 01 Aug 2017 21:45:04 +0200
parents 0cfe4a07c2ad
children bc0fee081e1e
line wrap: on
line diff
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -468,6 +468,31 @@ close_buffer(
     int		del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
     int		wipe_buf = (action == DOBUF_WIPE);
 
+#ifdef FEAT_TERMINAL
+    if (bt_terminal(buf))
+    {
+	if (term_job_running(buf->b_term))
+	{
+	    if (wipe_buf)
+		/* Wiping out a terminal buffer kills the job. */
+		free_terminal(buf);
+	    else
+	    {
+		/* The job keeps running, hide the buffer. */
+		del_buf = FALSE;
+		unload_buf = FALSE;
+	    }
+	}
+	else
+	{
+	    /* A terminal buffer is wiped out if the job has finished. */
+	    del_buf = TRUE;
+	    unload_buf = TRUE;
+	    wipe_buf = TRUE;
+	}
+    }
+    else
+#endif
     /*
      * Force unloading or deleting when 'bufhidden' says so.
      * The caller must take care of NOT deleting/freeing when 'bufhidden' is