[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] vi: fix replacement of single character with CR
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2019-02-08 12:03:36
Message-ID: CAK1hOcN_thB-sjJPDAqiTMOfMTX81xE3zBkzTChgYPQ8Wu4wDw () mail ! gmail ! com
[Download RAW message or body]
Applied, thanks!
On Sun, Feb 3, 2019 at 3:02 PM Ron Yorston <rmy@pobox.com> wrote:
>
> 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>
> ---
> editors/vi.c | 11 +++--------
> 1 file 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)
> case 'r': // r- replace the current char with user input
> c1 = get_one_char(); // get the replacement char
> if (*dot != '\n') {
> -#if ENABLE_FEATURE_VI_UNDO
> - undo_push(dot, 1, UNDO_DEL);
> - *dot = c1;
> - undo_push(dot, 1, UNDO_INS_CHAIN);
> -#else
> - *dot = c1;
> - modified_count++;
> -#endif
> + dot = text_hole_delete(dot, dot, ALLOW_UNDO);
> + dot = char_insert(dot, c1, ALLOW_UNDO_CHAIN);
> + dot_left();
> }
> end_cmd_q(); // stop adding to q
> break;
> --
> 2.20.1
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic