On Mo, 15 Jun 2015, Bohr Shaw wrote:
> This is how to reproduce:
>
> vim -Nu NORC
> :help|wincmd w|1quit
>
> I expect to quit the HELP window, but two windows are both quit and
> vim exits. If I leave out "wincmd w", it works as expected.
Hm, I am not sure, how this is supposed to work.
I find it often hard to predict, when Vim is going to be quit. So I
always expect the latter.
Nevertheless here is a patch, including a test, that fixes that. The
behaviour changes slightly:
command 7.4 patched
:h|wincmd w|:q - quits quits
:h|only|:q - quits quits
:h|wincmd w|:1q - quits does only close help window
:h|wincmd w|:.q - quits leaves help window open
Best,
Christian
--
Vernunft und Phantasie ist Religion - Vernunft und Verstand ist
Wissenschaft.
-- Novalis (eig. Georg Philipp Friedrich Leopold von Hardenberg)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -7092,7 +7092,15 @@ ex_quit(eap)
else
{
#ifdef FEAT_WINDOWS
- if (only_one_window()) /* quit last window */
+ /* quit last window
+ * Note: only_one_window() returns true, even so a
+ * help window is still open. In that case only quit,
+ * if no address has been specified.
+ * Example:
+ * :h|wincmd w|1q - don't quit
+ * :h|wincmd w|q - quit
+ */
+ if (only_one_window() && (firstwin == lastwin || eap->addr_count == 0))
#endif
getout(0);
#ifdef FEAT_WINDOWS
diff --git a/src/testdir/test13.in b/src/testdir/test13.in
--- a/src/testdir/test13.in
+++ b/src/testdir/test13.in
@@ -48,6 +48,12 @@ otestje3
:au BufWipeout Xtestje1 buf Xtestje1
:bwipe
:w >>test.out
+:only
+:help
+:wincmd w
+:1quit
+:$put ='Final line'
+:$w >>test.out
:qa!
ENDTEST
diff --git a/src/testdir/test13.ok b/src/testdir/test13.ok
--- a/src/testdir/test13.ok
+++ b/src/testdir/test13.ok
@@ -28,3 +28,4 @@ testje1
contents
contents
end of testfile
+Final line