aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-11-28 15:28:57 -0500
committerGitHub <noreply@github.com>2020-11-28 21:28:57 +0100
commita35c54b2aefc5baa720d98a9ba8c613bc40f694a (patch)
treee5bc069c2bf5c4c2d3030060fa0a9c7e545e41d7 /src
parent7294a20bbc64c646fcfe03c1e5519da348f258fe (diff)
downloadrneovim-a35c54b2aefc5baa720d98a9ba8c613bc40f694a.tar.gz
rneovim-a35c54b2aefc5baa720d98a9ba8c613bc40f694a.tar.bz2
rneovim-a35c54b2aefc5baa720d98a9ba8c613bc40f694a.zip
vim-patch:8.2.0095: cannot specify exit code for :cquit (#13407)
Problem: Cannot specify exit code for :cquit. Solution: Add optional argument. (Thinca, Yegappan Lakshmanan, closes vim/vim#5442) https://github.com/vim/vim/commit/1860bde9d31bbb0ba857f6284f6332a7134030dd Co-authored-by: erw7 <erw7.github@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c9
-rw-r--r--src/nvim/testdir/test_quickfix.vim27
2 files changed, 30 insertions, 6 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index d65387f83b..0ffe67a4db 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -6317,17 +6317,14 @@ static void ex_quit(exarg_T *eap)
}
}
-/*
- * ":cquit".
- */
+/// ":cquit".
static void ex_cquit(exarg_T *eap)
{
+ // this does not always pass on the exit code to the Manx compiler. why?
getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE);
}
-/*
- * ":qall": try to quit all windows
- */
+/// ":qall": try to quit all windows
static void ex_quit_all(exarg_T *eap)
{
if (cmdwin_type != 0) {
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 9c5f0777c6..5c84e45a79 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -3,6 +3,8 @@
source check.vim
CheckFeature quickfix
+source screendump.vim
+
set encoding=utf-8
func s:setup_commands(cchar)
@@ -4410,6 +4412,31 @@ func Test_search_in_dirstack()
call delete('Xtestdir', 'rf')
endfunc
+" Test for :cquit
+func Test_cquit()
+ " Exit Vim with a non-zero value
+ if RunVim([], ["cquit 7"], '')
+ call assert_equal(7, v:shell_error)
+ endif
+
+ if RunVim([], ["50cquit"], '')
+ call assert_equal(50, v:shell_error)
+ endif
+
+ " Exit Vim with default value
+ if RunVim([], ["cquit"], '')
+ call assert_equal(1, v:shell_error)
+ endif
+
+ " Exit Vim with zero value
+ if RunVim([], ["cquit 0"], '')
+ call assert_equal(0, v:shell_error)
+ endif
+
+ " Exit Vim with negative value
+ call assert_fails('-3cquit', 'E16:')
+endfunc
+
" Test for adding an invalid entry with the quickfix window open and making
" sure that the window contents are not changed
func Test_add_invalid_entry_with_qf_window()