• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révisionfab8455af19c86c2d0d82ba0f5e8a41dde38427f (tree)
l'heure2020-11-24 04:30:06
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.2.2036: buffer messed up if creating the quickfix window fails

Commit: https://github.com/vim/vim/commit/9e40c4b15ebfbc84947a3f34b1bd53e397b57f51
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 23 20:15:08 2020 +0100

patch 8.2.2036: buffer messed up if creating the quickfix window fails
Problem: Current buffer is messed up if creating a new buffer for the
quickfix window fails.
Solution: Check that creating the buffer succeeds. (closes #7352)

Change Summary

Modification

diff -r 088b92f86b6c -r fab8455af19c src/quickfix.c
--- a/src/quickfix.c Mon Nov 23 18:30:05 2020 +0100
+++ b/src/quickfix.c Mon Nov 23 20:30:06 2020 +0100
@@ -4151,13 +4151,15 @@
41514151 if (qf_buf != NULL)
41524152 {
41534153 // Use the existing quickfix buffer
4154- (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE,
4155- ECMD_HIDE + ECMD_OLDBUF, oldwin);
4154+ if (do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE,
4155+ ECMD_HIDE + ECMD_OLDBUF, oldwin) == FAIL)
4156+ return FAIL;
41564157 }
41574158 else
41584159 {
41594160 // Create a new quickfix buffer
4160- (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
4161+ if (do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin) == FAIL)
4162+ return FAIL;
41614163
41624164 // save the number of the new buffer
41634165 qi->qf_bufnr = curbuf->b_fnum;
diff -r 088b92f86b6c -r fab8455af19c src/testdir/dumps/Test_quickfix_window_fails.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_quickfix_window_fails.dump Mon Nov 23 20:30:06 2020 +0100
@@ -0,0 +1,13 @@
1+|a+0&#ffffff0|n|y|t|h|i|n|g| @66
2+> @74
3+|t|r|y| @71
4+|X+3&&|q|u|i|c|k|f|i|x|F|a|i|l|s| |[|+|]| @38|2|,|0|-|1| @9|T|o|p
5+| +0&&@74
6+|t|r|y| @71
7+@2|a|n|y|t|h|i|n|g| @64
8+|X+1&&|q|u|i|c|k|f|i|x|F|a|i|l|s| |[|+|]| @38|2|,|0|-|1| @9|5|0|%
9+| +0&&@74
10+|~+0#4040ff13&| @73
11+|~| @73
12+|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
13+| +0&&@74
diff -r 088b92f86b6c -r fab8455af19c src/testdir/test_quickfix.vim
--- a/src/testdir/test_quickfix.vim Mon Nov 23 18:30:05 2020 +0100
+++ b/src/testdir/test_quickfix.vim Mon Nov 23 20:30:06 2020 +0100
@@ -5218,4 +5218,39 @@
52185218 cclose
52195219 endfunc
52205220
5221+" Test for very weird problem: autocommand causes a failure, resulting opening
5222+" the quickfix window to fail. This still splits the window, but otherwise
5223+" should not mess up buffers.
5224+func Test_quickfix_window_fails_to_open()
5225+ CheckScreendump
5226+
5227+ let lines =<< trim END
5228+ anything
5229+ try
5230+ anything
5231+ endtry
5232+ END
5233+ call writefile(lines, 'XquickfixFails')
5234+
5235+ let lines =<< trim END
5236+ split XquickfixFails
5237+ silent vimgrep anything %
5238+ normal o
5239+ au BufLeave * ++once source XquickfixFails
5240+ " This will trigger the autocommand, which causes an error, what follows
5241+ " is aborted but the window was already split.
5242+ silent! cwindow
5243+ END
5244+ call writefile(lines, 'XtestWinFails')
5245+ let buf = RunVimInTerminal('-S XtestWinFails', #{rows: 13})
5246+ call VerifyScreenDump(buf, 'Test_quickfix_window_fails', {})
5247+
5248+ " clean up
5249+ call term_sendkeys(buf, ":bwipe!\<CR>")
5250+ call term_wait(buf)
5251+ call StopVimInTerminal(buf)
5252+ call delete('XtestWinFails')
5253+ call delete('XquickfixFails')
5254+endfunc
5255+
52215256 " vim: shiftwidth=2 sts=2 expandtab
diff -r 088b92f86b6c -r fab8455af19c src/version.c
--- a/src/version.c Mon Nov 23 18:30:05 2020 +0100
+++ b/src/version.c Mon Nov 23 20:30:06 2020 +0100
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 2036,
755+/**/
754756 2035,
755757 /**/
756758 2034,
Afficher sur ancien navigateur de dépôt.