Просмотр исходного кода

vi: fix backspace over tab in commands

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>
Ron Yorston 3 лет назад
Родитель
Сommit
50564aa2e7
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      editors/vi.c

+ 2 - 1
editors/vi.c

@@ -3030,10 +3030,11 @@ static char *get_input_line(const char *prompt)
             break;      // this is end of input
         if (isbackspace(c)) {
             // user wants to erase prev char
-            vi_puts("\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;
+            vi_puts(buf);
         } else if (c > 0 && c < 256) { // exclude Unicode
             // (TODO: need to handle Unicode)
             buf[i] = c;