vi: restore capability to remember insertion cmds for "."
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 2 Apr 2019 09:50:25 +0000 (11:50 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 2 Apr 2019 09:50:25 +0000 (11:50 +0200)
function                                             old     new   delta
modifying_cmds                                        17      22      +5
get_one_char                                         103      98      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-5)                Total: 0 bytes
   text    data     bss     dec     hex filename
 982121     485    7296  989902   f1ace busybox_old
 982094     485    7296  989875   f1ab3 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
editors/vi.c

index 993630d6f877af8bffe5a2ad1630a3f5d5237ae2..9d0fc23cf1b29241340c2abb25316827d9ee9f37 100644 (file)
@@ -244,9 +244,7 @@ enum {
 
 #if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
 // cmds modifying text[]
-// vda: removed "aAiIs" as they switch us into insert mode
-// and remembering input for replay after them makes no sense
-static const char modifying_cmds[] ALIGN1 = "cCdDJoOpPrRxX<>~";
+static const char modifying_cmds[] ALIGN1 = "aAcCdDiIJoOpPrRs""xX<>~";
 #endif
 
 enum {
@@ -1053,8 +1051,11 @@ static int get_one_char(void)
        }
        // we are adding STDIN chars to q.
        c = readit();
-       if (lmc_len >= MAX_INPUT_LEN - 1) {
-               status_line_bold("last_modifying_cmd overrun");
+       if (lmc_len >= ARRAY_SIZE(last_modifying_cmd) - 1) {
+               // last_modifying_cmd[] is too small, can't remeber the cmd
+               // - drop it
+               adding2q = 0;
+               lmc_len = 0;
        } else {
                last_modifying_cmd[lmc_len++] = c;
        }