From 24a7df9b09cf88dd186caebcc173ce6f4e44a027 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Fri, 1 Dec 2023 20:16:28 +0330 Subject: [PATCH] LibLine: Move the cursor to the beginning of the final line after ^C We previously left it at the end of the final line, which caused the next prompt to start offset to the right: |$ foo^C | $ This commit makes LibLine move to the beginning of that line, making it so the next prompt shows up at the beginning of the line: |$ foo^C |$ --- Userland/Libraries/LibLine/Editor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp index 4a64d207a2..ca15aeb78e 100644 --- a/Userland/Libraries/LibLine/Editor.cpp +++ b/Userland/Libraries/LibLine/Editor.cpp @@ -622,6 +622,7 @@ ErrorOr Editor::interrupted() TRY(reposition_cursor(*stderr_stream, true)); if (TRY(m_suggestion_display->cleanup())) TRY(reposition_cursor(*stderr_stream, true)); + TRY(stderr_stream->write_until_depleted("\r"sv.bytes())); } m_buffer.clear(); m_chars_touched_in_the_middle = buffer().size(); @@ -816,7 +817,7 @@ void Editor::handle_interrupt_event() m_previous_interrupt_was_handled_as_interrupt = true; - fprintf(stderr, "^C\r\n"); + fprintf(stderr, "^C\n"); fflush(stderr); if (on_interrupt_handled)