]> granicus.if.org Git - vim/commitdiff
patch 8.1.0337: :file fails in quickfix command v8.1.0337
authorBram Moolenaar <Bram@vim.org>
Thu, 30 Aug 2018 13:58:28 +0000 (15:58 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 30 Aug 2018 13:58:28 +0000 (15:58 +0200)
Problem:    :file fails in quickfix command.
Solution:   Allow :file without argument when curbuf_lock is set. (Jason
            Franklin)

src/ex_docmd.c
src/testdir/test_quickfix.vim
src/version.c

index c8a1c3f23854d03765c2d1dd162286105f92c592..5b53785cc51285bd062f07a0fc4f3187f13cdbef 100644 (file)
@@ -2039,12 +2039,15 @@ do_one_cmd(
            errormsg = (char_u *)_(get_text_locked_msg());
            goto doend;
        }
+
        /* Disallow editing another buffer when "curbuf_lock" is set.
-        * Do allow ":edit" (check for argument later).
-        * Do allow ":checktime" (it's postponed). */
+        * Do allow ":checktime" (it is postponed).
+        * Do allow ":edit" (check for an argument later).
+        * Do allow ":file" with no arguments (check for an argument later). */
        if (!(ea.argt & CMDWIN)
-               && ea.cmdidx != CMD_edit
                && ea.cmdidx != CMD_checktime
+               && ea.cmdidx != CMD_edit
+               && ea.cmdidx != CMD_file
                && !IS_USER_CMDIDX(ea.cmdidx)
                && curbuf_locked())
            goto doend;
@@ -2130,6 +2133,10 @@ do_one_cmd(
     else
        ea.arg = skipwhite(p);
 
+    // ":file" cannot be run with an argument when "curbuf_lock" is set
+    if (ea.cmdidx == CMD_file && *ea.arg != NUL && curbuf_locked())
+       goto doend;
+
     /*
      * Check for "++opt=val" argument.
      * Must be first, allow ":w ++enc=utf8 !cmd"
index 6063fd63cd2de379716d9763b5f94dfe32a9dbf2..36982c2298f7624ae3b4921221b62a0292891c28 100644 (file)
@@ -2485,6 +2485,35 @@ func Test_cclose_in_autocmd()
   call test_override('starting', 0)
 endfunc
 
+" Check that ":file" without an argument is possible even when "curbuf_lock"
+" is set.
+func Test_file_from_copen()
+  " Works without argument.
+  augroup QF_Test
+    au!
+    au FileType qf file
+  augroup END
+  copen
+
+  augroup QF_Test
+    au!
+  augroup END
+  cclose
+
+  " Fails with argument.
+  augroup QF_Test
+    au!
+    au FileType qf call assert_fails(':file foo', 'E788')
+  augroup END
+  copen
+  augroup QF_Test
+    au!
+  augroup END
+  cclose
+
+  augroup! QF_Test
+endfunction
+
 func Test_resize_from_copen()
     augroup QF_Test
        au!
index baf005ea3e2d20dc4c99f536320eb2fc78ad4039..12c86aaba72edb55d51900b9c02e1c1a7f7167de 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    337,
 /**/
     336,
 /**/