[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox-cvs
Subject:    [git commit] vi: fix backspace over tab in commands
From:       Bernhard Reutner-Fischer <rep.dot.nop () gmail ! com>
Date:       2022-04-20 14:06:04
Message-ID: 20220420135933.8D6FF83DBB () busybox ! osuosl ! org
[Download RAW message or body]

commit: https://git.busybox.net/busybox/commit/?id=c93eb1a95b1f06c145d4169a8776a318a2085e8b
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Colon and search commands are entered on the status line.  Since
the cursor position wasn't being tracked backspacing over a tab
resulted in a mismatch between the actual and apparent content
of the command.

function                                             old     new   delta
get_input_line                                       178     180      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 2/0)                 Total: 2 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 editors/vi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/editors/vi.c b/editors/vi.c
index 4257c0fdc..6fa0a4e18 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -1217,10 +1217,11 @@ static char *get_input_line(const char *prompt)
 			break;		// this is end of input
 		if (isbackspace(c)) {
 			// user wants to erase prev char
-			write1("\b \b"); // erase char on screen
 			buf[--i] = '\0';
+			go_bottom_and_clear_to_eol();
 			if (i <= 0) // user backs up before b-o-l, exit
 				break;
+			write1(buf);
 		} else if (c > 0 && c < 256) { // exclude Unicode
 			// (TODO: need to handle Unicode)
 			buf[i] = c;
_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic