Skip to content

Commit e561a7e

Browse files
committed
patch 8.0.1013: terminal window behaves different from a buffer with changes
Problem: A terminal window with a running job behaves different from a window containing a changed buffer. Solution: Do not set 'bufhidden' to "hide". Fix that a buffer where a terminal used to run is listed as "[Scratch]".
1 parent 48340b6 commit e561a7e

4 files changed

Lines changed: 16 additions & 15 deletions

File tree

runtime/doc/terminal.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*terminal.txt* For Vim version 8.0. Last change: 2017 Aug 26
1+
*terminal.txt* For Vim version 8.0. Last change: 2017 Aug 29
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -140,11 +140,17 @@ Syntax ~
140140
When the buffer associated with the terminal is unloaded or wiped out the job
141141
is killed, similar to calling `job_stop(job, "kill")`
142142

143-
By default the 'bufhidden' option of the buffer will be set to "hide".
144-
So long as the job is running: If the window is closed the buffer becomes
145-
hidden. The command will not be stopped. The `:buffer` command can be used
146-
to turn the current window into a terminal window. If there are unsaved
147-
changes this fails, use ! to force, as usual.
143+
So long as the job is running the window behaves like it contains a modified
144+
buffer. Trying to close the window with `CTRL-W :close` or `CTRL-W :hide`
145+
fails, unless "!" is added, in which case the job is ended. The text in the
146+
window is lost. The buffer still exists, but getting it in a window with
147+
`:buffer` will show an
148+
empty buffer.
149+
150+
You can use `CTRL-W :hide` to close the terminal window and make the buffer
151+
hidden, the job keeps running. The `:buffer` command can be used to turn the
152+
current window into a terminal window. If there are unsaved changes this
153+
fails, use ! to force, as usual.
148154

149155
To have a background job run without a window, and open the window when it's
150156
done, use options like this: >

src/buffer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5825,8 +5825,8 @@ buf_spname(buf_T *buf)
58255825
if (buf->b_term != NULL)
58265826
return term_get_status_text(buf->b_term);
58275827
#endif
5828-
if (buf->b_sfname != NULL)
5829-
return buf->b_sfname;
5828+
if (buf->b_fname != NULL)
5829+
return buf->b_fname;
58305830
return (char_u *)_("[Scratch]");
58315831
}
58325832

src/terminal.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@
4444
* - add test for giving error for invalid 'termsize' value.
4545
* - support minimal size when 'termsize' is "rows*cols".
4646
* - support minimal size when 'termsize' is empty?
47-
* - do not set bufhidden to "hide"? works like a buffer with changes.
48-
* document that CTRL-W :hide can be used.
4947
* - GUI: when using tabs, focus in terminal, click on tab does not work.
50-
* - When $HOME was set by Vim (MS-Windows), do not pass it to the job.
5148
* - GUI: when 'confirm' is set and trying to exit Vim, dialog offers to save
5249
* changes to "!shell".
5350
* (justrajdeep, 2017 Aug 22)
@@ -399,10 +396,6 @@ term_start(typval_T *argvar, jobopt_T *opt, int forceit)
399396
* the job finished. */
400397
curbuf->b_p_ma = FALSE;
401398

402-
/* Set 'bufhidden' to "hide": allow closing the window. */
403-
set_string_option_direct((char_u *)"bufhidden", -1,
404-
(char_u *)"hide", OPT_FREE|OPT_LOCAL, 0);
405-
406399
set_term_and_win_size(term);
407400
setup_job_options(opt, term->tl_rows, term->tl_cols);
408401

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
1013,
772774
/**/
773775
1012,
774776
/**/

0 commit comments

Comments
 (0)