diff options
author | Ron Yorston <rmy@pobox.com> | 2021-05-01 13:15:30 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-05-04 14:51:48 +0200 |
commit | 8e71f2aab8f9f893be7741af21a7c689cf165c66 (patch) | |
tree | 0e3d40f6be30deb895ded0a738008d62ed213dbb | |
parent | 24effc7a3f32b3d4e78779473ddc683848ac3cb0 (diff) | |
download | busybox-w32-8e71f2aab8f9f893be7741af21a7c689cf165c66.tar.gz busybox-w32-8e71f2aab8f9f893be7741af21a7c689cf165c66.tar.bz2 busybox-w32-8e71f2aab8f9f893be7741af21a7c689cf165c66.zip |
vi: :wq/:x should warn if there are more files to edit
':wq' or ':x' should issue a warning if there are more files to edit,
unless they're followed by '!'.
function old new delta
colon 3911 3960 +49
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 49/0) Total: 49 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/vi.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/editors/vi.c b/editors/vi.c index c7e7c67d5..4a7f8c3c2 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -3181,9 +3181,20 @@ static void colon(char *buf) | |||
3181 | modified_count = 0; | 3181 | modified_count = 0; |
3182 | last_modified_count = -1; | 3182 | last_modified_count = -1; |
3183 | } | 3183 | } |
3184 | if (cmd[0] == 'x' | 3184 | if (cmd[1] == 'n') { |
3185 | || cmd[1] == 'q' || cmd[1] == 'n' | 3185 | editing = 0; |
3186 | ) { | 3186 | } else if (cmd[0] == 'x' || cmd[1] == 'q') { |
3187 | // are there other files to edit? | ||
3188 | int n = cmdline_filecnt - optind - 1; | ||
3189 | if (n > 0) { | ||
3190 | if (useforce) { | ||
3191 | // force end of argv list | ||
3192 | optind = cmdline_filecnt; | ||
3193 | } else { | ||
3194 | status_line_bold("%u more file(s) to edit", n); | ||
3195 | goto ret; | ||
3196 | } | ||
3197 | } | ||
3187 | editing = 0; | 3198 | editing = 0; |
3188 | } | 3199 | } |
3189 | } | 3200 | } |