diff --git a/components/console/linenoise/linenoise.c b/components/console/linenoise/linenoise.c index 64fcf23a12..637e5cf8c0 100644 --- a/components/console/linenoise/linenoise.c +++ b/components/console/linenoise/linenoise.c @@ -930,14 +930,18 @@ static int linenoiseEdit(char *buf, size_t buflen, const char *prompt) return l.len; } - if ( (getMillis() - t1) < LINENOISE_PASTE_KEY_DELAY && c != ENTER) { - /* Pasting data, insert characters without formatting. - * This can only be performed when the cursor is at the end of the - * line. */ - if (linenoiseInsertPastedChar(&l,c)) { - return -1; - } - continue; + unsigned char uc = (unsigned char)c; + + if ((getMillis() - t1) < LINENOISE_PASTE_KEY_DELAY && + uc >= 0x20 && + uc != BACKSPACE && + c != ENTER) { + /* Fast path only for printable pasted bytes. + * Control keys must go through normal key handling. */ + if (linenoiseInsertPastedChar(&l, c)) { + return -1; + } + continue; } /* Only autocomplete when the callback is set. It returns < 0 when