diff --git a/src/nnn.c b/src/nnn.c index 3961b0dd5..a4475b417 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -3718,13 +3718,13 @@ static char *xreadline(const char *prefill, const char *prompt) continue; case CONTROL('W'): printmsg(prompt); - do { - if (pos == 0) - break; - memmove(buf + pos - 1, buf + pos, - (len - pos) * WCHAR_T_WIDTH); - --pos, --len; - } while (buf[pos - 1] != ' ' && buf[pos - 1] != '/'); // NOLINT + lpos = pos; + while (pos > 0 && ISSPACE_(buf[pos - 1])) + --pos; + while (pos > 0 && !ISSPACE_(buf[pos - 1])) + --pos; + memmove(buf + pos, buf + lpos, (len - lpos) * WCHAR_T_WIDTH); + len -= lpos - pos; continue; case CONTROL('K'): printmsg(prompt);