From d54479c3e09fa8aaeb5838ee00ed407ce7a65d44 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sat, 4 Apr 2020 11:16:54 +0200 Subject: Let ctrl-U do the expected thing --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 062c080..3527410 100644 --- a/src/main.rs +++ b/src/main.rs @@ -105,8 +105,10 @@ fn handle_key(key: Key, st: &mut State) -> Option { // Editing Key::Ctrl('u') => { - st.input_buffer.clear(); - print!("\r{}{}", termion::clear::CurrentLine, PROMPT_STR); + st.input_buffer.drain(..st.input_cursor); + print!("\r{}{}{}\r{}", + PROMPT_STR, st.input_buffer, termion::clear::UntilNewline, + termion::cursor::Right(PROMPT_STR.len() as u16)); st.input_cursor = 0; } Key::Backspace => { -- cgit v1.2.3-70-g09d2