mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-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 vim/vim#2205)
Also for "2q" when a help window is open. Add a test.
2c33d7bb69
This commit is contained in:
parent
9fe8e3cb2f
commit
4d6ba4d06a
@ -6025,6 +6025,7 @@ static void ex_quit(exarg_T *eap)
|
|||||||
if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) {
|
if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) {
|
||||||
getout(0);
|
getout(0);
|
||||||
}
|
}
|
||||||
|
not_exiting();
|
||||||
// close window; may free buffer
|
// close window; may free buffer
|
||||||
win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit);
|
win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit);
|
||||||
}
|
}
|
||||||
@ -6382,6 +6383,7 @@ static void ex_exit(exarg_T *eap)
|
|||||||
// quit last window, exit Vim
|
// quit last window, exit Vim
|
||||||
getout(0);
|
getout(0);
|
||||||
}
|
}
|
||||||
|
not_exiting();
|
||||||
// Quit current window, may free the buffer.
|
// Quit current window, may free the buffer.
|
||||||
win_close(curwin, !buf_hide(curwin->w_buffer));
|
win_close(curwin, !buf_hide(curwin->w_buffer));
|
||||||
}
|
}
|
||||||
|
@ -31,3 +31,47 @@ func Test_writefile_fails_gently()
|
|||||||
|
|
||||||
call assert_fails('call writefile([], [])', 'E730:')
|
call assert_fails('call writefile([], [])', 'E730:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func SetFlag(timer)
|
||||||
|
let g:flag = 1
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_write_quit_split()
|
||||||
|
" Prevent exiting by splitting window on file write.
|
||||||
|
augroup testgroup
|
||||||
|
autocmd BufWritePre * split
|
||||||
|
augroup END
|
||||||
|
e! Xfile
|
||||||
|
call setline(1, 'nothing')
|
||||||
|
wq
|
||||||
|
|
||||||
|
if has('timers')
|
||||||
|
" timer will not run if "exiting" is still set
|
||||||
|
let g:flag = 0
|
||||||
|
call timer_start(1, 'SetFlag')
|
||||||
|
sleep 50m
|
||||||
|
call assert_equal(1, g:flag)
|
||||||
|
unlet g:flag
|
||||||
|
endif
|
||||||
|
au! testgroup
|
||||||
|
bwipe Xfile
|
||||||
|
call delete('Xfile')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_nowrite_quit_split()
|
||||||
|
" Prevent exiting by opening a help window.
|
||||||
|
e! Xfile
|
||||||
|
help
|
||||||
|
wincmd w
|
||||||
|
exe winnr() . 'q'
|
||||||
|
|
||||||
|
if has('timers')
|
||||||
|
" timer will not run if "exiting" is still set
|
||||||
|
let g:flag = 0
|
||||||
|
call timer_start(1, 'SetFlag')
|
||||||
|
sleep 50m
|
||||||
|
call assert_equal(1, g:flag)
|
||||||
|
unlet g:flag
|
||||||
|
endif
|
||||||
|
bwipe Xfile
|
||||||
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user