Skip to content

Commit 2c33d7b

Browse files
committed
patch 8.0.1190: unusable after opening new window in BufWritePre event
Problem: Vim becomes unusable after opening new window in BufWritePre event. Solution: Call not_exiting(). (Martin Tournoij, closes #2205) Also for "2q" when a help window is open. Add a test.
1 parent 6047e2c commit 2c33d7b

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

src/ex_docmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7261,6 +7261,7 @@ ex_quit(exarg_T *eap)
72617261
*/
72627262
if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0))
72637263
getout(0);
7264+
not_exiting();
72647265
#ifdef FEAT_GUI
72657266
need_mouse_correct = TRUE;
72667267
#endif
@@ -7799,6 +7800,7 @@ ex_exit(exarg_T *eap)
77997800
{
78007801
if (only_one_window()) /* quit last window, exit Vim */
78017802
getout(0);
7803+
not_exiting();
78027804
# ifdef FEAT_GUI
78037805
need_mouse_correct = TRUE;
78047806
# endif

src/testdir/test_writefile.vim

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,47 @@ func Test_writefile_fails_conversion()
4949
bwipe!
5050
set backup& writebackup&
5151
endfunc
52+
53+
func SetFlag(timer)
54+
let g:flag = 1
55+
endfunc
56+
57+
func Test_write_quit_split()
58+
" Prevent exiting by splitting window on file write.
59+
augroup testgroup
60+
autocmd BufWritePre * split
61+
augroup END
62+
e! Xfile
63+
call setline(1, 'nothing')
64+
wq
65+
66+
if has('timers')
67+
" timer will not run if "exiting" is still set
68+
let g:flag = 0
69+
call timer_start(1, 'SetFlag')
70+
sleep 50m
71+
call assert_equal(1, g:flag)
72+
unlet g:flag
73+
endif
74+
au! testgroup
75+
bwipe Xfile
76+
call delete('Xfile')
77+
endfunc
78+
79+
func Test_nowrite_quit_split()
80+
" Prevent exiting by opening a help window.
81+
e! Xfile
82+
help
83+
wincmd w
84+
exe winnr() . 'q'
85+
86+
if has('timers')
87+
" timer will not run if "exiting" is still set
88+
let g:flag = 0
89+
call timer_start(1, 'SetFlag')
90+
sleep 50m
91+
call assert_equal(1, g:flag)
92+
unlet g:flag
93+
endif
94+
bwipe Xfile
95+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1190,
764766
/**/
765767
1189,
766768
/**/

0 commit comments

Comments
 (0)