Skip to content

Commit 26910de

Browse files
committed
patch 8.1.1547: functionality of bt_nofile() is confusing
Problem: Functionality of bt_nofile() is confusing. Solution: Split into bt_nofile() and bt_nofilename().
1 parent 0331faf commit 26910de

9 files changed

Lines changed: 26 additions & 14 deletions

File tree

src/buffer.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5698,14 +5698,23 @@ bt_popup(buf_T *buf)
56985698
* buffer. This means the buffer name is not a file name.
56995699
*/
57005700
int
5701-
bt_nofile(buf_T *buf)
5701+
bt_nofilename(buf_T *buf)
57025702
{
57035703
return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
57045704
|| buf->b_p_bt[0] == 'a'
57055705
|| buf->b_p_bt[0] == 't'
57065706
|| buf->b_p_bt[0] == 'p');
57075707
}
57085708

5709+
/*
5710+
* Return TRUE if "buf" has 'buftype' set to "nofile".
5711+
*/
5712+
int
5713+
bt_nofile(buf_T *buf)
5714+
{
5715+
return buf != NULL && buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f';
5716+
}
5717+
57095718
/*
57105719
* Return TRUE if "buf" is a "nowrite", "nofile", "terminal" or "prompt"
57115720
* buffer.
@@ -5772,7 +5781,7 @@ buf_spname(buf_T *buf)
57725781

57735782
/* There is no _file_ when 'buftype' is "nofile", b_sfname
57745783
* contains the name as specified by the user. */
5775-
if (bt_nofile(buf))
5784+
if (bt_nofilename(buf))
57765785
{
57775786
#ifdef FEAT_TERMINAL
57785787
if (buf->b_term != NULL)

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1943,7 +1943,7 @@ find_buffer(typval_T *avar)
19431943
if (buf->b_fname != NULL
19441944
&& (path_with_url(buf->b_fname)
19451945
#ifdef FEAT_QUICKFIX
1946-
|| bt_nofile(buf)
1946+
|| bt_nofilename(buf)
19471947
#endif
19481948
)
19491949
&& STRCMP(buf->b_fname, avar->vval.v_string) == 0)

src/ex_cmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3399,7 +3399,7 @@ check_overwrite(
33993399
|| (buf->b_flags & BF_READERR))
34003400
&& !p_wa
34013401
#ifdef FEAT_QUICKFIX
3402-
&& !bt_nofile(buf)
3402+
&& !bt_nofilename(buf)
34033403
#endif
34043404
&& vim_fexists(ffname))
34053405
{

src/ex_docmd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9909,7 +9909,7 @@ makeopens(
99099909
&& wp->w_buffer->b_ffname != NULL
99109910
&& !bt_help(wp->w_buffer)
99119911
#ifdef FEAT_QUICKFIX
9912-
&& !bt_nofile(wp->w_buffer)
9912+
&& !bt_nofilename(wp->w_buffer)
99139913
#endif
99149914
)
99159915
{
@@ -10236,7 +10236,7 @@ ses_do_win(win_T *wp)
1023610236
if (wp->w_buffer->b_fname == NULL
1023710237
#ifdef FEAT_QUICKFIX
1023810238
/* When 'buftype' is "nofile" can't restore the window contents. */
10239-
|| bt_nofile(wp->w_buffer)
10239+
|| bt_nofilename(wp->w_buffer)
1024010240
#endif
1024110241
)
1024210242
return (ssop_flags & SSOP_BLANK);
@@ -10323,7 +10323,7 @@ put_view(
1032310323
*/
1032410324
if (wp->w_buffer->b_ffname != NULL
1032510325
# ifdef FEAT_QUICKFIX
10326-
&& !bt_nofile(wp->w_buffer)
10326+
&& !bt_nofilename(wp->w_buffer)
1032710327
# endif
1032810328
)
1032910329
{

src/fileio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3160,7 +3160,7 @@ buf_write(
31603160
&& whole
31613161
&& buf == curbuf
31623162
#ifdef FEAT_QUICKFIX
3163-
&& !bt_nofile(buf)
3163+
&& !bt_nofilename(buf)
31643164
#endif
31653165
&& !filtering
31663166
&& (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL)
@@ -3237,7 +3237,7 @@ buf_write(
32373237
sfname, sfname, FALSE, curbuf, eap)))
32383238
{
32393239
#ifdef FEAT_QUICKFIX
3240-
if (overwriting && bt_nofile(curbuf))
3240+
if (overwriting && bt_nofilename(curbuf))
32413241
nofile_err = TRUE;
32423242
else
32433243
#endif
@@ -3270,7 +3270,7 @@ buf_write(
32703270
else
32713271
{
32723272
#ifdef FEAT_QUICKFIX
3273-
if (overwriting && bt_nofile(curbuf))
3273+
if (overwriting && bt_nofilename(curbuf))
32743274
nofile_err = TRUE;
32753275
else
32763276
#endif
@@ -3284,7 +3284,7 @@ buf_write(
32843284
sfname, sfname, FALSE, curbuf, eap)))
32853285
{
32863286
#ifdef FEAT_QUICKFIX
3287-
if (overwriting && bt_nofile(curbuf))
3287+
if (overwriting && bt_nofilename(curbuf))
32883288
nofile_err = TRUE;
32893289
else
32903290
#endif
@@ -6083,7 +6083,7 @@ shorten_buf_fname(buf_T *buf, char_u *dirname, int force)
60836083

60846084
if (buf->b_fname != NULL
60856085
#ifdef FEAT_QUICKFIX
6086-
&& !bt_nofile(buf)
6086+
&& !bt_nofilename(buf)
60876087
#endif
60886088
&& !path_with_url(buf->b_fname)
60896089
&& (force

src/popupmnu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ pum_set_selected(int n, int repeat)
727727
if (!resized
728728
&& curbuf->b_nwindows == 1
729729
&& curbuf->b_fname == NULL
730-
&& curbuf->b_p_bt[0] == 'n' && curbuf->b_p_bt[2] == 'f'
730+
&& bt_nofile(curbuf)
731731
&& curbuf->b_p_bh[0] == 'w')
732732
{
733733
/* Already a "wipeout" buffer, make it empty. */

src/proto/buffer.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ int bt_terminal(buf_T *buf);
6262
int bt_help(buf_T *buf);
6363
int bt_prompt(buf_T *buf);
6464
int bt_popup(buf_T *buf);
65+
int bt_nofilename(buf_T *buf);
6566
int bt_nofile(buf_T *buf);
6667
int bt_dontwrite(buf_T *buf);
6768
int bt_dontwrite_msg(buf_T *buf);

src/quickfix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4135,7 +4135,7 @@ qf_open_new_cwindow(qf_info_T *qi, int height)
41354135
// Set the options for the quickfix buffer/window (if not already done)
41364136
// Do this even if the quickfix buffer was already present, as an autocmd
41374137
// might have previously deleted (:bdelete) the quickfix buffer.
4138-
if (curbuf->b_p_bt[0] != 'q')
4138+
if (bt_quickfix(curbuf))
41394139
qf_set_cwindow_options();
41404140

41414141
// Only set the height when still in the same tab page and there is no

src/version.c

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

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1547,
780782
/**/
781783
1546,
782784
/**/

0 commit comments

Comments
 (0)