However, the current buffer has been splitted into 2 or more windows
and use :{count}q command to a window of other buffers,
that window is quitted without warning and any changes is lost.
This happens on 8.0.2 and 8.0.1203.
I am not exactly sure but the following change in ex_docmd.c may fix the problem.
Looks like the current buffer is to be quitted as of 8.0.1203.
--- ex_docmdX.c 2017-10-16 18:16:44.114732500 +0900
+++ ex_docmd.c 2017-10-16 18:46:28.990821600 +0900
@@ -7224,10 +7224,10 @@
wp = curwin;
#ifdef FEAT_AUTOCMD
- apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf);
+ apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, wp->w_buffer);
/* Refuse to quit when locked or when the buffer in the last window is
* being closed (can only happen in autocommands). */
- if (curbuf_locked() || !win_valid(wp)
+ if (!win_valid(wp)
|| (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0))
return;
#endif
@@ -7241,8 +7241,8 @@
*/
if (check_more(FALSE, eap->forceit) == OK && only_one_window())
exiting = TRUE;
- if ((!buf_hide(curbuf)
- && check_changed(curbuf, (p_awa ? CCGD_AW : 0)
+ if ((!buf_hide(wp->w_buffer)
+ && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0)
| (eap->forceit ? CCGD_FORCEIT : 0)
| CCGD_EXCMD))
|| check_more(TRUE, eap->forceit) == FAIL
vim foo.txt
:split
:new
[add some text]
:3wincmd w
:1q
then the 1st window is quitted without E37 warning.
And QuitPre event is passed to the 1st (current) buffer, not 2nd.
BTW I can't find any documentation about :[count]q in the Vim help (in
particular editing.txt, last change 2017 Aug 21; and version8.txt,
last change 2017 Apr 23). :[range]wq refers to the lines to be
written, which is obviously not what this thread is about.