Browse Source

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
    |$
Ali Mohammad Pur 1 year ago
parent
commit
24a7df9b09
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Userland/Libraries/LibLine/Editor.cpp

+ 2 - 1
Userland/Libraries/LibLine/Editor.cpp

@@ -622,6 +622,7 @@ ErrorOr<void> 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)