Skip to content

Commit

Permalink
fix bug in Ctrl-W in xreadline implementation
Browse files Browse the repository at this point in the history
when there's multiple spaces, the previous logic didn't erase
them, E.g:

    a word   |   < before
    a word  |    < after Ctrl-w

this patch brings the behavior closer to readlines:

    a word   |   < before
    a |          < after Ctrl-w

this also slightly changes the behavior since '/' is no longer
considered a boundary.
  • Loading branch information
N-R-K committed Dec 16, 2024
1 parent 0337196 commit 1c1211b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1c1211b

Please sign in to comment.