]> granicus.if.org Git - vim/commitdiff
patch 8.1.1547: functionality of bt_nofile() is confusing v8.1.1547
authorBram Moolenaar <Bram@vim.org>
Sat, 15 Jun 2019 17:37:15 +0000 (19:37 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 15 Jun 2019 17:37:15 +0000 (19:37 +0200)
Problem:    Functionality of bt_nofile() is confusing.
Solution:   Split into bt_nofile() and bt_nofilename().

src/buffer.c
src/evalfunc.c
src/ex_cmds.c
src/ex_docmd.c
src/fileio.c
src/popupmnu.c
src/proto/buffer.pro
src/quickfix.c
src/version.c

index e6ae09d255588b2182c565128f167c6ce336c92e..c3911ae2bb9d4d011c088145abac1af4510d5d1e 100644 (file)
@@ -5698,7 +5698,7 @@ bt_popup(buf_T *buf)
  * buffer.  This means the buffer name is not a file name.
  */
     int
-bt_nofile(buf_T *buf)
+bt_nofilename(buf_T *buf)
 {
     return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
            || buf->b_p_bt[0] == 'a'
@@ -5706,6 +5706,15 @@ bt_nofile(buf_T *buf)
            || buf->b_p_bt[0] == 'p');
 }
 
+/*
+ * Return TRUE if "buf" has 'buftype' set to "nofile".
+ */
+    int
+bt_nofile(buf_T *buf)
+{
+    return buf != NULL && buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f';
+}
+
 /*
  * Return TRUE if "buf" is a "nowrite", "nofile", "terminal" or "prompt"
  * buffer.
@@ -5772,7 +5781,7 @@ buf_spname(buf_T *buf)
 
     /* There is no _file_ when 'buftype' is "nofile", b_sfname
      * contains the name as specified by the user. */
-    if (bt_nofile(buf))
+    if (bt_nofilename(buf))
     {
 #ifdef FEAT_TERMINAL
        if (buf->b_term != NULL)
index 0ef76095f404bd2d7ab580e3dd7d8537e47962e9..544426fa6d71c0820af6ac9caa4c17420eaad087 100644 (file)
@@ -1943,7 +1943,7 @@ find_buffer(typval_T *avar)
                if (buf->b_fname != NULL
                        && (path_with_url(buf->b_fname)
 #ifdef FEAT_QUICKFIX
-                           || bt_nofile(buf)
+                           || bt_nofilename(buf)
 #endif
                           )
                        && STRCMP(buf->b_fname, avar->vval.v_string) == 0)
index d7a4187b8636e56883d4b53416a7fa3c41ac2708..d1068c7cff33d276e01d7eb8edc13b2fd9d5f9ac 100644 (file)
@@ -3399,7 +3399,7 @@ check_overwrite(
                || (buf->b_flags & BF_READERR))
            && !p_wa
 #ifdef FEAT_QUICKFIX
-           && !bt_nofile(buf)
+           && !bt_nofilename(buf)
 #endif
            && vim_fexists(ffname))
     {
index 91ced52a5f8ad2b8d440680d91ab9126a8c96517..438cb355aa02e6392515c71feaf050315828b563 100644 (file)
@@ -9909,7 +9909,7 @@ makeopens(
                    && wp->w_buffer->b_ffname != NULL
                    && !bt_help(wp->w_buffer)
 #ifdef FEAT_QUICKFIX
-                   && !bt_nofile(wp->w_buffer)
+                   && !bt_nofilename(wp->w_buffer)
 #endif
                    )
            {
@@ -10236,7 +10236,7 @@ ses_do_win(win_T *wp)
     if (wp->w_buffer->b_fname == NULL
 #ifdef FEAT_QUICKFIX
            /* When 'buftype' is "nofile" can't restore the window contents. */
-           || bt_nofile(wp->w_buffer)
+           || bt_nofilename(wp->w_buffer)
 #endif
        )
        return (ssop_flags & SSOP_BLANK);
@@ -10323,7 +10323,7 @@ put_view(
         */
        if (wp->w_buffer->b_ffname != NULL
 # ifdef FEAT_QUICKFIX
-               && !bt_nofile(wp->w_buffer)
+               && !bt_nofilename(wp->w_buffer)
 # endif
                )
        {
index e6fb6bfaee142bb59b7352c5136909c4e57afa26..03183255e3044b0ad1b82ee7eb9c6c60cc4bfca2 100644 (file)
@@ -3160,7 +3160,7 @@ buf_write(
            && whole
            && buf == curbuf
 #ifdef FEAT_QUICKFIX
-           && !bt_nofile(buf)
+           && !bt_nofilename(buf)
 #endif
            && !filtering
            && (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL)
@@ -3237,7 +3237,7 @@ buf_write(
                                         sfname, sfname, FALSE, curbuf, eap)))
            {
 #ifdef FEAT_QUICKFIX
-               if (overwriting && bt_nofile(curbuf))
+               if (overwriting && bt_nofilename(curbuf))
                    nofile_err = TRUE;
                else
 #endif
@@ -3270,7 +3270,7 @@ buf_write(
            else
            {
 #ifdef FEAT_QUICKFIX
-               if (overwriting && bt_nofile(curbuf))
+               if (overwriting && bt_nofilename(curbuf))
                    nofile_err = TRUE;
                else
 #endif
@@ -3284,7 +3284,7 @@ buf_write(
                                         sfname, sfname, FALSE, curbuf, eap)))
            {
 #ifdef FEAT_QUICKFIX
-               if (overwriting && bt_nofile(curbuf))
+               if (overwriting && bt_nofilename(curbuf))
                    nofile_err = TRUE;
                else
 #endif
@@ -6083,7 +6083,7 @@ shorten_buf_fname(buf_T *buf, char_u *dirname, int force)
 
     if (buf->b_fname != NULL
 #ifdef FEAT_QUICKFIX
-           && !bt_nofile(buf)
+           && !bt_nofilename(buf)
 #endif
            && !path_with_url(buf->b_fname)
            && (force
index 09faa69e88083d0508af89f8e71f3f2edae6f3ae..5fbb3bbd284f8db8df96dff703c434d8f460c469 100644 (file)
@@ -727,7 +727,7 @@ pum_set_selected(int n, int repeat)
                if (!resized
                        && curbuf->b_nwindows == 1
                        && curbuf->b_fname == NULL
-                       && curbuf->b_p_bt[0] == 'n' && curbuf->b_p_bt[2] == 'f'
+                       && bt_nofile(curbuf)
                        && curbuf->b_p_bh[0] == 'w')
                {
                    /* Already a "wipeout" buffer, make it empty. */
index 1748fb51f857510cd3239e3acca9ca87c59d0691..81be7e4bd03f849accc9213e162d0aaf1b65d58f 100644 (file)
@@ -62,6 +62,7 @@ int bt_terminal(buf_T *buf);
 int bt_help(buf_T *buf);
 int bt_prompt(buf_T *buf);
 int bt_popup(buf_T *buf);
+int bt_nofilename(buf_T *buf);
 int bt_nofile(buf_T *buf);
 int bt_dontwrite(buf_T *buf);
 int bt_dontwrite_msg(buf_T *buf);
index 290f6bcccc416184f1c10b08874a7652eaa1f44d..d2d33026360c5a1d36a8203cd6899ea56ab0caaf 100644 (file)
@@ -4135,7 +4135,7 @@ qf_open_new_cwindow(qf_info_T *qi, int height)
     // Set the options for the quickfix buffer/window (if not already done)
     // Do this even if the quickfix buffer was already present, as an autocmd
     // might have previously deleted (:bdelete) the quickfix buffer.
-    if (curbuf->b_p_bt[0] != 'q')
+    if (bt_quickfix(curbuf))
        qf_set_cwindow_options();
 
     // Only set the height when still in the same tab page and there is no
index 675beb8f8c03f56b1d102b14737dfe70bbfacadc..113fb97ce0b6d564c7d8a66a03ce179e4b3ed3aa 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1547,
 /**/
     1546,
 /**/