commit ff5084479b57f2ae440c54a48f83d63cbb838c52
parent 97f4a3f4ebb268590247d11ccf692346bef8c7ea
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sat, 29 Jan 2022 17:18:37 +0100
prompt: let ^K erase text after cursor (if any), otherwise whole answer
In most cases, the cursor will be at the end of what the user typed
at the prompt (or retrieved from history), and ^K will work as it
always did, erasing the whole answer. But if the user has moved the
cursor to somewhere in the middle of the answer, a ^K will now erase
just the part after the cursor. A second ^K will erase the rest.
Inspired-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/prompt.c b/src/prompt.c
@@ -157,10 +157,10 @@ void do_statusbar_backspace(void)
}
}
-/* Zap some or all text from the answer. */
+/* Zap the part of the answer after the cursor, or the whole answer. */
void do_statusbar_cut_text(void)
{
- if (!ISSET(CUT_FROM_CURSOR))
+ if (answer[typing_x] == '\0')
typing_x = 0;
answer[typing_x] = '\0';