Hi Bram,
2014-11-24(Mon) 7:28:36 UTC+9 Bram Moolenaar:
> Hirohito Higashi wrote:
>
> > 2014/11/23(Sun) 0:03:33 UTC+9 Bram Moolenaar:
> > > Hirohito Higashi wrote:
> > >
> > > > 2014/11/22(Sat) 11:08:53 UTC+9 h_east:
> > > > > Hi Bram and All,
> > > > >
> > > > > 2014/11/22(Sat) 7:02:29 UTC+9 Bram Moolenaar:
> > > > > > Yasuhiro Matsumoto wrote:
> > > > > >
> > > > > > > > Then the behavior would be:
> > > > > > > > vim -o a.txt b.txt c.txt
> > > > > > > > [make a change in each window]
> > > > > > > > :hide (hides a.txt, still modified)
> > > > > > > > :q! (removes modified flag from b.txt, only see
> > > > > > > > c.txt now)
> > > > > > > > :q! (removes modified flag from c.txt, error,
> > > > > > > > switches to a.txt)
> > > > > > > > :q! (exits)
> > > > > > >
> > > > > > > https://gist.github.com/0dcb7a098130ed8682b6
> > > > > > >
> > > > > > > This patch should work as above.
> > > > > >
> > > > > > Thanks! I'll check it out.
> > > > >
> > > > > I came up with a better way.
> > > > > Please wait a few hour.
> > > >
> > > > I attach a patch. (Contains a document patch)
> > > > Please check this.
> > >
> > > Thanks. Since this is basic functionality, it would be nice to have a
> > > test for ":q!".
> >
> > I added a test for ":q!".
> > Update a patch.
> > I checked test is OK, when patched. and checked fail, when non patched.
> > Please check this.
>
> Thanks!
I update a patch for 7.4.972
This patch can be found in the todo list.
todo> ":q!" should reset modified flag for current buffer, if another buffer is
todo> modified no need to abandon it again.
todo> Patch from Yasuhiro Matsumoto, 2014 Nov 21.
todo> Update from Hirohito Higashi, 2014 Nov 21.
todo> With test, Nov 23.
--
Best regards,
Hirohito Higashi (a.k.a h_east)
--
--
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/runtime/doc/editing.txt b/runtime/doc/editing.txt
index 5666e68..1a1fe59 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -1106,10 +1106,9 @@ The names can be in upper- or lowercase.
edited. See |:confirm| and 'confirm'. {not in Vi}
:q[uit]! Quit without writing, also when currently visible
- buffers have changes. Does not exit when this is the
- last window and there is a changed hidden buffer.
- In this case, the first changed hidden buffer becomes
- the current buffer.
+ buffers have changes. If this is the last window and
+ there is a modified hidden buffer, the first changed
+ hidden buffer becomes the current buffer.
Use ":qall!" to exit always.
:cq[uit] Quit always, without writing, and return an error
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 30f9e9d..82fa294 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -1638,8 +1638,9 @@ add_bufnum(bufnrs, bufnump, nr)
* That changed buffer becomes the current buffer.
*/
int
-check_changed_any(hidden)
+check_changed_any(hidden, unload)
int hidden; /* Only check hidden buffers */
+ int unload; /* Unload curbuf if return TRUE */
{
int ret = FALSE;
buf_T *buf;
@@ -1750,7 +1751,7 @@ buf_found:
/* Open the changed buffer in the current window. */
if (buf != curbuf)
- set_curbuf(buf, DOBUF_GOTO);
+ set_curbuf(buf, unload ? DOBUF_UNLOAD : DOBUF_GOTO);
theend:
vim_free(bufnrs);
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 31b51e9..91fe188 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -7142,7 +7142,7 @@ ex_quit(eap)
| (eap->forceit ? CCGD_FORCEIT : 0)
| CCGD_EXCMD))
|| check_more(TRUE, eap->forceit) == FAIL
- || (only_one_window() && check_changed_any(eap->forceit)))
+ || (only_one_window() && check_changed_any(eap->forceit, TRUE)))
{
not_exiting();
}
@@ -7213,7 +7213,7 @@ ex_quit_all(eap)
#endif
exiting = TRUE;
- if (eap->forceit || !check_changed_any(FALSE))
+ if (eap->forceit || !check_changed_any(FALSE, FALSE))
getout(0);
not_exiting();
}
@@ -7608,7 +7608,7 @@ ex_exit(eap)
|| curbufIsChanged())
&& do_write(eap) == FAIL)
|| check_more(TRUE, eap->forceit) == FAIL
- || (only_one_window() && check_changed_any(eap->forceit)))
+ || (only_one_window() && check_changed_any(eap->forceit, FALSE)))
{
not_exiting();
}
diff --git a/src/gui.c b/src/gui.c
index 0736522..ec732e0 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -825,7 +825,7 @@ gui_shell_closed()
# endif
/* If there are changed buffers, present the user with a dialog if
* possible, otherwise give an error message. */
- if (!check_changed_any(FALSE))
+ if (!check_changed_any(FALSE, FALSE))
getout(0);
exiting = FALSE;
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 9b3bf61..dc95e17 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -1997,7 +1997,7 @@ sm_client_check_changed_any(GnomeClient *client UNUSED,
* If there are changed buffers, present the user with
* a dialog if possible, otherwise give an error message.
*/
- shutdown_cancelled = check_changed_any(FALSE);
+ shutdown_cancelled = check_changed_any(FALSE, FALSE);
exiting = FALSE;
cmdmod = save_cmdmod;
diff --git a/src/os_unix.c b/src/os_unix.c
index 314a906..f85231a 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -7205,7 +7205,7 @@ xsmp_handle_interaction(smc_conn, client_data)
save_cmdmod = cmdmod;
cmdmod.confirm = TRUE;
- if (check_changed_any(FALSE))
+ if (check_changed_any(FALSE, FALSE))
/* Mustn't logout */
cancel_shutdown = True;
cmdmod = save_cmdmod;
diff --git a/src/proto/ex_cmds2.pro b/src/proto/ex_cmds2.pro
index 0ac3e14..8875851 100644
--- a/src/proto/ex_cmds2.pro
+++ b/src/proto/ex_cmds2.pro
@@ -39,7 +39,7 @@ int check_changed __ARGS((buf_T *buf, int flags));
void browse_save_fname __ARGS((buf_T *buf));
void dialog_changed __ARGS((buf_T *buf, int checkall));
int can_abandon __ARGS((buf_T *buf, int forceit));
-int check_changed_any __ARGS((int hidden));
+int check_changed_any __ARGS((int hidden, int unload));
int check_fname __ARGS((void));
int buf_write_all __ARGS((buf_T *buf, int forceit));
int get_arglist __ARGS((garray_T *gap, char_u *str));
diff --git a/src/testdir/test31.in b/src/testdir/test31.in
index 7dc2334..3ba8431 100644
--- a/src/testdir/test31.in
+++ b/src/testdir/test31.in
@@ -69,6 +69,26 @@ A 3:close!
GA 4:all!
:1wincmd w
:w >>test.out
+:"
+:" test ":q!" and hidden buffer.
+:bw! Xtest1 Xtest2 Xtest3 Xtest4
+:sp Xtest1
+:wincmd w
+:bw!
+:set modified
+:bot sp Xtest2
+:set modified
+:bot sp Xtest3
+:set modified
+:wincmd t
+:hide
+:q!
+:w >>test.out
+:q!
+:w >>test.out
+:q!
+:call append(line('$'), "Oh, Not finished yet.")
+:w >>test.out
:qa!
ENDTEST
diff --git a/src/testdir/test31.ok b/src/testdir/test31.ok
index 185bdc7..3953197 100644
--- a/src/testdir/test31.ok
+++ b/src/testdir/test31.ok
@@ -10,3 +10,5 @@ testtext 1
testtext 3 3 3
testtext 1
testtext 2 2 2
+testtext 3
+testtext 1