summaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorYee Cheng Chin <ychin.git@gmail.com>2022-10-10 11:46:16 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-10 11:46:16 +0100
commit4282633ba63f6e11f2fe42c4b7758dace184f30d (patch)
tree529b9b35b2358aa7247ad4029348dabaaffc0262 /src/buffer.c
parentf167c7b42476f8ab5b32c3c5ccbdca914316e96b (diff)
patch 9.0.0710: quitting/unloading/hiding a terminal does not work properlyv9.0.0710
Problem: Quitting/unloading/hiding a terminal buffer does not always work properly. Solution: Avoid that ":q!" leaves an empty buffer behind. ":bunload!" also kills the job and unloads the buffer. ":hide" does not unload the buffer. (Yee Cheng Chin, closes #11323)
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 97b41e0a89..b589894b7e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -538,7 +538,8 @@ close_buffer(
unload_buf = TRUE;
#ifdef FEAT_TERMINAL
- if (bt_terminal(buf) && (buf->b_nwindows == 1 || del_buf))
+ // depending on how we get here b_nwindows may already be zero
+ if (bt_terminal(buf) && (buf->b_nwindows <= 1 || del_buf))
{
CHECK_CURBUF;
if (term_job_running(buf->b_term))
@@ -550,6 +551,11 @@ close_buffer(
// Wiping out or unloading a terminal buffer kills the job.
free_terminal(buf);
+
+ // A terminal buffer is wiped out when job has finished.
+ del_buf = TRUE;
+ unload_buf = TRUE;
+ wipe_buf = TRUE;
}
else
{
@@ -565,10 +571,16 @@ close_buffer(
}
else
{
- // A terminal buffer is wiped out if the job has finished.
- del_buf = TRUE;
- unload_buf = TRUE;
- wipe_buf = TRUE;
+ if (del_buf || unload_buf)
+ {
+ // A terminal buffer is wiped out if the job has finished.
+ // We only do this when there's an intention to unload the
+ // buffer. This way, :hide and other similar commands won't
+ // wipe the buffer.
+ del_buf = TRUE;
+ unload_buf = TRUE;
+ wipe_buf = TRUE;
+ }
}
CHECK_CURBUF;
}