]> granicus.if.org Git - vim/commitdiff
patch 7.4.1037 v7.4.1037
authorBram Moolenaar <Bram@vim.org>
Sat, 2 Jan 2016 21:25:52 +0000 (22:25 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 2 Jan 2016 21:25:52 +0000 (22:25 +0100)
Problem:    Using "q!" when there is a modified hidden buffer does not unload
            the current buffer, resulting in the need to abandon it again.
Solution:   When using "q!" unload the current buffer when needed. (Yasuhiro
            Matsumoto, Hirohito Higashi)

runtime/doc/editing.txt
src/ex_cmds2.c
src/ex_docmd.c
src/gui.c
src/gui_gtk_x11.c
src/os_unix.c
src/proto/ex_cmds2.pro
src/testdir/test31.in
src/testdir/test31.ok
src/version.c

index 5666e68b5a72f739febb5195989f6f6051113ba1..4c013e9f5c1e80ff7a8790dc2874f2c638451f7c 100644 (file)
@@ -1105,10 +1105,10 @@ The names can be in upper- or lowercase.
                        the last file in the argument list has not been
                        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
+:q[uit]!               Quit without writing, also when currentl buffer has
+                       changes.  If this is the last window and there is a
+                       modified hidden buffer, the current buffer is
+                       abandoned and the first changed hidden buffer becomes
                        the current buffer.
                        Use ":qall!" to exit always.
 
index 30f9e9d18b5755e33b63af5ed76c32720e33667f..05baa7e99eb5cd8d871d18ec2a6be42f48ca1040 100644 (file)
@@ -1636,10 +1636,13 @@ add_bufnum(bufnrs, bufnump, nr)
 /*
  * Return TRUE if any buffer was changed and cannot be abandoned.
  * That changed buffer becomes the current buffer.
+ * When "unload" is true the current buffer is unloaded instead of making it
+ * hidden.  This is used for ":q!".
  */
     int
-check_changed_any(hidden)
+check_changed_any(hidden, unload)
     int                hidden;         /* Only check hidden buffers */
+    int                unload;
 {
     int                ret = FALSE;
     buf_T      *buf;
@@ -1750,7 +1753,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);
index 648cc0d77091b078b94bdc16a5a90334929fb14a..ac713dc13cdc33be90500c7fa9c97f2947238627 100644 (file)
@@ -7143,7 +7143,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();
     }
@@ -7214,7 +7214,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();
 }
@@ -7609,7 +7609,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();
     }
index 07365224d303a2de5ca32e949d5d30ee983e798a..ec732e001ce99d927cedc6e8fe80c8a0900b3cd6 100644 (file)
--- 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;
index e543b0a3754dfe9eb64970272e1e246431fa5c80..9967795e07949325083eea0400ef260663b59a99 100644 (file)
@@ -2003,7 +2003,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;
index d4a0f6dbe8f230e6257d36862129095e237c2cdb..36196369cb429eb3131db86fae25f34e6e86af58 100644 (file)
@@ -7132,7 +7132,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;
index 0ac3e149245c3d032fe2b4637f2fb0f64d7f76ad..88758517f2a9bfd62bb0528a4bcb612e6db77a27 100644 (file)
@@ -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));
index 7dc233478175c9f2ef23507655694f75b07f27b1..3ba8431ccf6e6a3efb68ae57a332d046d95ba41c 100644 (file)
@@ -69,6 +69,26 @@ A 3\e:close!
 GA 4\e: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
 
index 185bdc768e28e209b9b33dc4f8c357619b9b88a1..39531974c668559c3526e24bed561a5070876dbc 100644 (file)
@@ -10,3 +10,5 @@ testtext 1
 testtext 3 3 3
 testtext 1
 testtext 2 2 2
+testtext 3
+testtext 1
index 48c848529b6dc50de0071f0b725baa8875c3d192..0ca4f8ab9536ed9f8b8f89056e3981774cb3785f 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1037,
 /**/
     1036,
 /**/