]> granicus.if.org Git - vim/commitdiff
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing v8.1.1049
authorBram Moolenaar <Bram@vim.org>
Mon, 25 Mar 2019 21:21:24 +0000 (22:21 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 25 Mar 2019 21:21:24 +0000 (22:21 +0100)
Problem:    When user tries to exit with CTRL-C message is confusing.
Solution:   Only mention ":qa!" when there is a changed buffer. (closes #4163)

src/normal.c
src/proto/undo.pro
src/testdir/test_normal.vim
src/undo.c
src/version.c

index 477907520bcf806bbe49d74a8cdb411e562cb929..f99c7e3ecf94597f73ced53a3fd612c03091e587 100644 (file)
@@ -8886,7 +8886,12 @@ nv_esc(cmdarg_T *cap)
 #endif
                && !VIsual_active
                && no_reason)
-           msg(_("Type  :qa!  and press <Enter> to abandon all changes and exit Vim"));
+       {
+           if (anyBufIsChanged())
+               msg(_("Type  :qa!  and press <Enter> to abandon all changes and exit Vim"));
+           else
+               msg(_("Type  :qa  and press <Enter> to exit Vim"));
+       }
 
        /* Don't reset "restart_edit" when 'insertmode' is set, it won't be
         * set again below when halfway a mapping. */
index 1052d40c2bf995e63a19b329bd343cffb7520b12..f2190bfea9eda72dd57d82f0ebecb73d8ac6dd22 100644 (file)
@@ -25,6 +25,7 @@ void u_clearline(void);
 void u_undoline(void);
 void u_blockfree(buf_T *buf);
 int bufIsChanged(buf_T *buf);
+int anyBufIsChanged(void);
 int bufIsChangedNotTerm(buf_T *buf);
 int curbufIsChanged(void);
 void u_eval_tree(u_header_T *first_uhp, list_T *list);
index 1224a3f7da2bf8e7555fa423242f81af9588ded1..4c63bb8ab0b5e6850b1751e8b5042d97b46186c4 100644 (file)
@@ -1,5 +1,7 @@
 " Test for various Normal mode commands
 
+source shared.vim
+
 func Setup_NewWindow()
   10new
   call setline(1, range(1,100))
@@ -2542,3 +2544,13 @@ func Test_nv_hat_count()
 
   %bwipeout!
 endfunc
+
+func Test_message_when_using_ctrl_c()
+  exe "normal \<C-C>"
+  call assert_match("Type  :qa  and press <Enter> to exit Vim", Screenline(&lines))
+  new
+  cal setline(1, 'hi!')
+  exe "normal \<C-C>"
+  call assert_match("Type  :qa!  and press <Enter> to abandon all changes and exit Vim", Screenline(&lines))
+  bwipe!
+endfunc
index b2d1d9f1151a39335c5483eb1baca444f94b3450..4fd58a33238e025dfab995b94a05f3dc2a915080 100644 (file)
@@ -3530,6 +3530,19 @@ bufIsChanged(buf_T *buf)
     return bufIsChangedNotTerm(buf);
 }
 
+/*
+ * Return TRUE if any buffer has changes.  Also buffers that are not written.
+ */
+    int
+anyBufIsChanged(void)
+{
+    buf_T *buf;
+
+    FOR_ALL_BUFFERS(buf)
+       if (bufIsChanged(buf))
+           return TRUE;
+}
+
 /*
  * Like bufIsChanged() but ignoring a terminal window.
  */
index d5e8c8b591abc7db95f5cd1ba159a215cb5b7c22..f0da22a48933a9a3563bb5ce0fc761c592946683 100644 (file)
@@ -775,6 +775,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1049,
 /**/
     1048,
 /**/