mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 17:58:18 +00:00
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)
1860bde9d3
Co-authored-by: erw7 <erw7.github@gmail.com>
This commit is contained in:
@@ -187,12 +187,17 @@ processing a quickfix or location list command, it will be aborted.
|
|||||||
current window is used instead of the quickfix list.
|
current window is used instead of the quickfix list.
|
||||||
|
|
||||||
*:cq* *:cquit*
|
*:cq* *:cquit*
|
||||||
:[count]cq[uit] Quit Nvim with an error code, or the code specified in
|
:cq[uit][!]
|
||||||
[count]. Useful when Nvim is called from another
|
:{N}cq[uit][!]
|
||||||
program: e.g. `git commit` will abort the comitting
|
:cq[uit][!] {N} Quit Vim with error code {N}. {N} defaults to one.
|
||||||
process, `fc` (built-in for shells like bash and zsh)
|
Useful when Vim is called from another program:
|
||||||
will not execute the command.
|
e.g., a compiler will not compile the same file again,
|
||||||
|
`git commit` will abort the committing process, `fc`
|
||||||
|
(built-in for shells like bash and zsh) will not
|
||||||
|
execute the command, etc. will not compile the same
|
||||||
|
file again.
|
||||||
|
{N} can also be zero, in which case Vim exits
|
||||||
|
normally.
|
||||||
WARNING: All changes in files are lost. It works like
|
WARNING: All changes in files are lost. It works like
|
||||||
":qall!" |:qall|, except that Nvim exits non-zero or
|
":qall!" |:qall|, except that Nvim exits non-zero or
|
||||||
[count].
|
[count].
|
||||||
|
@@ -6317,17 +6317,14 @@ static void ex_quit(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// ":cquit".
|
||||||
* ":cquit".
|
|
||||||
*/
|
|
||||||
static void ex_cquit(exarg_T *eap)
|
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);
|
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)
|
static void ex_quit_all(exarg_T *eap)
|
||||||
{
|
{
|
||||||
if (cmdwin_type != 0) {
|
if (cmdwin_type != 0) {
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
source check.vim
|
source check.vim
|
||||||
CheckFeature quickfix
|
CheckFeature quickfix
|
||||||
|
|
||||||
|
source screendump.vim
|
||||||
|
|
||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
|
|
||||||
func s:setup_commands(cchar)
|
func s:setup_commands(cchar)
|
||||||
@@ -4410,6 +4412,31 @@ func Test_search_in_dirstack()
|
|||||||
call delete('Xtestdir', 'rf')
|
call delete('Xtestdir', 'rf')
|
||||||
endfunc
|
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
|
" Test for adding an invalid entry with the quickfix window open and making
|
||||||
" sure that the window contents are not changed
|
" sure that the window contents are not changed
|
||||||
func Test_add_invalid_entry_with_qf_window()
|
func Test_add_invalid_entry_with_qf_window()
|
||||||
|
Reference in New Issue
Block a user