Skip to content

Commit 4c32c1e

Browse files
committed
xreadline ctrl-w memmove less
1 parent f38bc6f commit 4c32c1e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/nnn.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3716,13 +3716,17 @@ static char *xreadline(const char *prefill, const char *prompt)
37163716
continue;
37173717
case CONTROL('W'):
37183718
printmsg(prompt);
3719+
lpos = pos;
37193720
do {
3720-
if (pos == 0)
3721+
if (pos <= 0)
37213722
break;
3722-
memmove(buf + pos - 1, buf + pos,
3723-
(len - pos) * WCHAR_T_WIDTH);
3724-
--pos, --len;
3723+
--pos;
37253724
} while (buf[pos - 1] != ' ' && buf[pos - 1] != '/'); // NOLINT
3725+
if (pos < lpos) {
3726+
if (len > lpos)
3727+
memmove(buf + pos, buf + lpos, (len - lpos) * WCHAR_T_WIDTH);
3728+
len -= lpos - pos;
3729+
}
37263730
continue;
37273731
case CONTROL('K'):
37283732
printmsg(prompt);

0 commit comments

Comments
 (0)