aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-02-03 14:01:58 +0000
committerDenys Vlasenko <vda.linux@googlemail.com>2019-02-08 13:03:06 +0100
commitdf4e3af9f716e0483bd02fd4ab3ad973ffe5b998 (patch)
tree1feec53a2fd3c7f49134322f4538daac935e1f87
parentbb983f30e7ea69604212793f228270f21e8a5b06 (diff)
downloadbusybox-w32-df4e3af9f716e0483bd02fd4ab3ad973ffe5b998.tar.gz
busybox-w32-df4e3af9f716e0483bd02fd4ab3ad973ffe5b998.tar.bz2
busybox-w32-df4e3af9f716e0483bd02fd4ab3ad973ffe5b998.zip
vi: fix replacement of single character with CR
Currently if the 'r' command is followed by a carriage return a literal CR replaces the current character. Fix this so that: - a new line is inserted - the autoindent setting is respected - the cursor is placed at the start of the new line function old new delta do_cmd 5052 5060 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 8/0) Total: 8 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/vi.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/editors/vi.c b/editors/vi.c
index c6adeb311..899fcf57e 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -4189,14 +4189,9 @@ static void do_cmd(int c)
4189 case 'r': // r- replace the current char with user input 4189 case 'r': // r- replace the current char with user input
4190 c1 = get_one_char(); // get the replacement char 4190 c1 = get_one_char(); // get the replacement char
4191 if (*dot != '\n') { 4191 if (*dot != '\n') {
4192#if ENABLE_FEATURE_VI_UNDO 4192 dot = text_hole_delete(dot, dot, ALLOW_UNDO);
4193 undo_push(dot, 1, UNDO_DEL); 4193 dot = char_insert(dot, c1, ALLOW_UNDO_CHAIN);
4194 *dot = c1; 4194 dot_left();
4195 undo_push(dot, 1, UNDO_INS_CHAIN);
4196#else
4197 *dot = c1;
4198 modified_count++;
4199#endif
4200 } 4195 }
4201 end_cmd_q(); // stop adding to q 4196 end_cmd_q(); // stop adding to q
4202 break; 4197 break;