Mercurial > vim
diff src/normal.c @ 30467:072c61082148 v9.0.0569
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Commit: https://github.com/vim/vim/commit/5939c357431f8e43853ad80b03303167f39763df
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 24 12:50:45 2022 +0100
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Problem: Cannot easily get out when using "vim file | grep word".
Solution: Without changes let CTRL-C exit Vim. Otherwise give a message on
stderr. (closes #11209)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 24 Sep 2022 14:00:04 +0200 |
parents | 914b3c64ab92 |
children | 584231b9b37e |
line wrap: on
line diff
--- a/src/normal.c +++ b/src/normal.c @@ -6793,10 +6793,33 @@ nv_esc(cmdarg_T *cap) && !VIsual_active && no_reason) { + int out_redir = !stdout_isatty +#ifdef FEAT_GUI + && !gui.in_use +#endif + ; + // The user may accidentally do "vim file | grep word" and then + // CTRL-C doesn't show anything. With a changed buffer give the + // message on stderr. Without any changes might as well exit. if (anyBufIsChanged()) - msg(_("Type :qa! and press <Enter> to abandon all changes and exit Vim")); + { + char *ms = _("Type :qa! and press <Enter> to abandon all changes and exit Vim"); + + if (out_redir) + mch_errmsg(ms); + else + msg(ms); + } else - msg(_("Type :qa and press <Enter> to exit Vim")); + { + if (out_redir) + { + got_int = FALSE; + do_cmdline_cmd((char_u *)"qa"); + } + else + msg(_("Type :qa and press <Enter> to exit Vim")); + } } if (restart_edit != 0)