I noticed that this was still in the "todo.txt" file. I had some free time today, so I decided to fix it.
> Using ":file" in quickfix window during an autocommand doesn't work. > (Jason Franklin, 2018 May 23) Allow for using it when there is no argument. A failing test is included (both cases are checked). Let me know if this works. Thanks, Jason -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
From ca96132f2d03bdac3a91283560a10f35d3475fe1 Mon Sep 17 00:00:00 2001 From: Jason Franklin <[email protected]> Date: Sun, 12 Aug 2018 11:51:49 -0400 Subject: [PATCH 1/2] Add failing test --- src/testdir/test_quickfix.vim | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim index ce19e74d3..fd4f17d38 100644 --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -2485,6 +2485,42 @@ func Test_cclose_in_autocmd() call test_override('starting', 0) endfunc +" Patch 8.0.0677 set the "curbuf_lock" variable when the 'ft' option assumed +" the "qf" value. This meant that a call to ":file" from within a quickfix +" ftplugin would then fail. This test ensures that ":file" remains allowed in +" this context when no arguments are included (i.e., when the buffer name is +" not being altered). +func Test_file_from_copen() + + " With no argument. + augroup QF_Test + au! + au FileType qf file + augroup END + try + copen + catch /E788/ + call assert_report('":file" failed in during copen') + endtry + augroup QF_Test + au! + augroup + cclose + + " 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! -- 2.17.1 From f6552a98ccbb5e87cc04eafdb69cfb070b517d6a Mon Sep 17 00:00:00 2001 From: Jason Franklin <[email protected]> Date: Sun, 12 Aug 2018 11:58:44 -0400 Subject: [PATCH 2/2] Allow :file with no args when curbuf_lock is set --- src/ex_docmd.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 51aa06888..f58ece6aa 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -2231,12 +2231,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; @@ -2322,6 +2325,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 && STRCMP(ea.arg, "") != 0 && curbuf_locked()) + goto doend; + /* * Check for "++opt=val" argument. * Must be first, allow ":w ++enc=utf8 !cmd" -- 2.17.1
