fix(console): bug where backspace erases the prompt in dumb mode

pull/13557/merge
Guillaume Souchere 2024-04-17 10:17:52 +02:00
rodzic 624bcb4757
commit aa61062584
1 zmienionych plików z 9 dodań i 3 usunięć

Wyświetl plik

@ -1136,10 +1136,16 @@ static int linenoiseDumb(char* buf, size_t buflen, const char* prompt) {
} else if (c == BACKSPACE || c == 0x8) {
if (count > 0) {
buf[count - 1] = 0;
count --;
count--;
/* Only erase symbol echoed from stdin. */
fputs("\x08 ", stdout); /* Windows CMD: erase symbol under cursor */
flushWrite();
} else {
/* Consume backspace if the command line is empty to avoid erasing the prompt */
continue;
}
fputs("\x08 ", stdout); /* Windows CMD: erase symbol under cursor */
flushWrite();
} else {
buf[count] = c;
++count;