aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2018-11-09 03:33:28 -0500
committerJustin M. Keyes <justinkz@gmail.com>2018-11-09 09:33:28 +0100
commit18435a25347eeecb0886281d278c060aa7f82f6c (patch)
tree960c021db06ee706866e3c536c9aa1bc2f37b055
parent16bc1e9c17824e3a68f3b93152fc6f98583f6d58 (diff)
downloadrneovim-18435a25347eeecb0886281d278c060aa7f82f6c.tar.gz
rneovim-18435a25347eeecb0886281d278c060aa7f82f6c.tar.bz2
rneovim-18435a25347eeecb0886281d278c060aa7f82f6c.zip
vim-patch:8.1.0337: :file fails in quickfix command (#9215)
Problem: :file fails in quickfix command. Solution: Allow :file without argument when curbuf_lock is set. (Jason Franklin) https://github.com/vim/vim/commit/379fb76b080521f7c09265ec3264b9e698923518
-rw-r--r--src/nvim/ex_docmd.c19
-rw-r--r--src/nvim/testdir/test_quickfix.vim29
2 files changed, 43 insertions, 5 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 6ac7656a2f..6361267d9b 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1804,15 +1804,19 @@ static char_u * do_one_cmd(char_u **cmdlinep,
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). */
+
+ // Disallow editing another buffer when "curbuf_lock" is set.
+ // 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())
+ && curbuf_locked()) {
goto doend;
+ }
if (!ni && !(ea.argt & RANGE) && ea.addr_count > 0) {
/* no range allowed */
@@ -1884,6 +1888,11 @@ static char_u * do_one_cmd(char_u **cmdlinep,
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"
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 624e642e7f..bfe5791ec8 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -2235,6 +2235,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!