summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-03-25 22:21:24 +0100
committerBram Moolenaar <Bram@vim.org>2019-03-25 22:21:24 +0100
commita84a3dd6635fcd2e07f510cba6a999585dcc381a (patch)
tree5ec1f6fef107b2cf8fe33a5bf5bb04fd9edc6999
parentb45125b374cc3a1cef176b704f518c72c518f24c (diff)
downloadvim-git-a84a3dd6635fcd2e07f510cba6a999585dcc381a.tar.gz
patch 8.1.1049: when user tries to exit with CTRL-C message is confusingv8.1.1049
Problem: When user tries to exit with CTRL-C message is confusing. Solution: Only mention ":qa!" when there is a changed buffer. (closes #4163)
-rw-r--r--src/normal.c7
-rw-r--r--src/proto/undo.pro1
-rw-r--r--src/testdir/test_normal.vim12
-rw-r--r--src/undo.c13
-rw-r--r--src/version.c2
5 files changed, 34 insertions, 1 deletions
diff --git a/src/normal.c b/src/normal.c
index 477907520..f99c7e3ec 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -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. */
diff --git a/src/proto/undo.pro b/src/proto/undo.pro
index 1052d40c2..f2190bfea 100644
--- a/src/proto/undo.pro
+++ b/src/proto/undo.pro
@@ -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);
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index 1224a3f7d..4c63bb8ab 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -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
diff --git a/src/undo.c b/src/undo.c
index b2d1d9f11..4fd58a332 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -3531,6 +3531,19 @@ bufIsChanged(buf_T *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.
*/
int
diff --git a/src/version.c b/src/version.c
index d5e8c8b59..f0da22a48 100644
--- a/src/version.c
+++ b/src/version.c
@@ -776,6 +776,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1049,
+/**/
1048,
/**/
1047,