diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/quickfix.c | 10 | ||||
-rw-r--r-- | src/nvim/testdir/test_quickfix.vim | 35 |
2 files changed, 42 insertions, 3 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index d3ca65c53c..3d7d587ed2 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3608,11 +3608,15 @@ static int qf_open_new_cwindow(qf_info_T *qi, int height) } if (qf_buf != NULL) { // Use the existing quickfix buffer - (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, - ECMD_HIDE + ECMD_OLDBUF, oldwin); + if (do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, + ECMD_HIDE + ECMD_OLDBUF, oldwin) == FAIL) { + return FAIL; + } } else { // Create a new quickfix buffer - (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin); + if (do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin) == FAIL) { + return FAIL; + } } // Set the options for the quickfix buffer/window (if not already done) diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 3e97cd2dd0..9c5f0777c6 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -4423,4 +4423,39 @@ func Test_add_invalid_entry_with_qf_window() cclose endfunc +" Test for very weird problem: autocommand causes a failure, resulting opening +" the quickfix window to fail. This still splits the window, but otherwise +" should not mess up buffers. +func Test_quickfix_window_fails_to_open() + CheckScreendump + + let lines =<< trim END + anything + try + anything + endtry + END + call writefile(lines, 'XquickfixFails') + + let lines =<< trim END + split XquickfixFails + silent vimgrep anything % + normal o + au BufLeave * ++once source XquickfixFails + " This will trigger the autocommand, which causes an error, what follows + " is aborted but the window was already split. + silent! cwindow + END + call writefile(lines, 'XtestWinFails') + let buf = RunVimInTerminal('-S XtestWinFails', #{rows: 13}) + call VerifyScreenDump(buf, 'Test_quickfix_window_fails', {}) + + " clean up + call term_sendkeys(buf, ":bwipe!\<CR>") + call term_wait(buf) + call StopVimInTerminal(buf) + call delete('XtestWinFails') + call delete('XquickfixFails') +endfunc + " vim: shiftwidth=2 sts=2 expandtab |