Mercurial > vim
comparison src/buffer.c @ 11757:74abb6c84984 v8.0.0761
patch 8.0.0761: options not set properly for a terminal buffer
commit https://github.com/vim/vim/commit/1f2903c43109b16594d141a730659317b15f388d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 23 19:51:01 2017 +0200
patch 8.0.0761: options not set properly for a terminal buffer
Problem: Options of a buffer for a terminal window are not set properly.
Solution: Add "terminal" value for 'buftype'. Make 'buftype' and
'bufhidden' not depend on the quickfix feature.
Also set the buffer name and show "running" or "finished" in the
window title.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 23 Jul 2017 20:00:05 +0200 |
parents | ce434212d682 |
children | f33b9375ba03 |
comparison
equal
deleted
inserted
replaced
11756:e3e89d6460d0 | 11757:74abb6c84984 |
---|---|
466 #endif | 466 #endif |
467 int unload_buf = (action != 0); | 467 int unload_buf = (action != 0); |
468 int del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE); | 468 int del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE); |
469 int wipe_buf = (action == DOBUF_WIPE); | 469 int wipe_buf = (action == DOBUF_WIPE); |
470 | 470 |
471 #ifdef FEAT_QUICKFIX | |
472 /* | 471 /* |
473 * Force unloading or deleting when 'bufhidden' says so. | 472 * Force unloading or deleting when 'bufhidden' says so. |
474 * The caller must take care of NOT deleting/freeing when 'bufhidden' is | 473 * The caller must take care of NOT deleting/freeing when 'bufhidden' is |
475 * "hide" (otherwise we could never free or delete a buffer). | 474 * "hide" (otherwise we could never free or delete a buffer). |
476 */ | 475 */ |
485 unload_buf = TRUE; | 484 unload_buf = TRUE; |
486 wipe_buf = TRUE; | 485 wipe_buf = TRUE; |
487 } | 486 } |
488 else if (buf->b_p_bh[0] == 'u') /* 'bufhidden' == "unload" */ | 487 else if (buf->b_p_bh[0] == 'u') /* 'bufhidden' == "unload" */ |
489 unload_buf = TRUE; | 488 unload_buf = TRUE; |
490 #endif | |
491 | 489 |
492 #ifdef FEAT_AUTOCMD | 490 #ifdef FEAT_AUTOCMD |
493 /* Disallow deleting the buffer when it is locked (already being closed or | 491 /* Disallow deleting the buffer when it is locked (already being closed or |
494 * halfway a command that relies on it). Unloading is allowed. */ | 492 * halfway a command that relies on it). Unloading is allowed. */ |
495 if (buf->b_locked > 0 && (del_buf || wipe_buf)) | 493 if (buf->b_locked > 0 && (del_buf || wipe_buf)) |
1980 # ifdef FEAT_EVAL | 1978 # ifdef FEAT_EVAL |
1981 if (aborting()) /* autocmds may abort script processing */ | 1979 if (aborting()) /* autocmds may abort script processing */ |
1982 return NULL; | 1980 return NULL; |
1983 # endif | 1981 # endif |
1984 #endif | 1982 #endif |
1985 #ifdef FEAT_QUICKFIX | 1983 #ifdef FEAT_AUTOCMD |
1986 # ifdef FEAT_AUTOCMD | |
1987 if (buf == curbuf) | 1984 if (buf == curbuf) |
1988 # endif | 1985 #endif |
1989 { | 1986 { |
1990 /* Make sure 'bufhidden' and 'buftype' are empty */ | 1987 /* Make sure 'bufhidden' and 'buftype' are empty */ |
1991 clear_string_option(&buf->b_p_bh); | 1988 clear_string_option(&buf->b_p_bh); |
1992 clear_string_option(&buf->b_p_bt); | 1989 clear_string_option(&buf->b_p_bt); |
1993 } | 1990 } |
1994 #endif | |
1995 } | 1991 } |
1996 if (buf != curbuf || curbuf == NULL) | 1992 if (buf != curbuf || curbuf == NULL) |
1997 { | 1993 { |
1998 buf = (buf_T *)alloc_clear((unsigned)sizeof(buf_T)); | 1994 buf = (buf_T *)alloc_clear((unsigned)sizeof(buf_T)); |
1999 if (buf == NULL) | 1995 if (buf == NULL) |
2163 { | 2159 { |
2164 #ifdef FEAT_MBYTE | 2160 #ifdef FEAT_MBYTE |
2165 clear_string_option(&buf->b_p_fenc); | 2161 clear_string_option(&buf->b_p_fenc); |
2166 #endif | 2162 #endif |
2167 clear_string_option(&buf->b_p_ff); | 2163 clear_string_option(&buf->b_p_ff); |
2168 #ifdef FEAT_QUICKFIX | |
2169 clear_string_option(&buf->b_p_bh); | 2164 clear_string_option(&buf->b_p_bh); |
2170 clear_string_option(&buf->b_p_bt); | 2165 clear_string_option(&buf->b_p_bt); |
2171 #endif | |
2172 } | 2166 } |
2173 #ifdef FEAT_FIND_ID | 2167 #ifdef FEAT_FIND_ID |
2174 clear_string_option(&buf->b_p_def); | 2168 clear_string_option(&buf->b_p_def); |
2175 clear_string_option(&buf->b_p_inc); | 2169 clear_string_option(&buf->b_p_inc); |
2176 # ifdef FEAT_EVAL | 2170 # ifdef FEAT_EVAL |
3666 off += 2; | 3660 off += 2; |
3667 #endif | 3661 #endif |
3668 /* remove the file name */ | 3662 /* remove the file name */ |
3669 p = gettail_sep(buf + off); | 3663 p = gettail_sep(buf + off); |
3670 if (p == buf + off) | 3664 if (p == buf + off) |
3671 /* must be a help buffer */ | 3665 { |
3672 vim_strncpy(buf + off, (char_u *)_("help"), | 3666 char *txt; |
3667 | |
3668 #ifdef FEAT_TERMINAL | |
3669 if (curbuf->b_term != NULL) | |
3670 txt = term_job_running(curbuf) | |
3671 ? _("running") : _("finished"); | |
3672 else | |
3673 #endif | |
3674 txt = _("help"); | |
3675 | |
3676 /* must be a help or terminal buffer */ | |
3677 vim_strncpy(buf + off, (char_u *)txt, | |
3673 (size_t)(SPACE_FOR_DIR - off - 1)); | 3678 (size_t)(SPACE_FOR_DIR - off - 1)); |
3679 } | |
3674 else | 3680 else |
3675 *p = NUL; | 3681 *p = NUL; |
3676 | 3682 |
3677 /* Translate unprintable chars and concatenate. Keep some | 3683 /* Translate unprintable chars and concatenate. Keep some |
3678 * room for the server name. When there is no room (very long | 3684 * room for the server name. When there is no room (very long |