From 39d14c22d18bc0a32b98c2ba377a17e988107e25 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Mon, 7 Sep 2020 07:37:54 +0430 Subject: [PATCH] LibLine: Treat ^D as EOF only when the buffer is empty As opposed to when the cursor is at the start of the buffer. Fixes #3421. --- Libraries/LibLine/Editor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp index 76c7eaa553e..542aa6d5916 100644 --- a/Libraries/LibLine/Editor.cpp +++ b/Libraries/LibLine/Editor.cpp @@ -738,7 +738,8 @@ void Editor::handle_read_event() // Normally ^D. `stty eof \^n` can change it to ^N (or something else), but Serenity doesn't have `stty` yet. // Process this here since the keybinds might override its behaviour. - if (code_point == m_termios.c_cc[VEOF] && m_cursor == 0) { + // This only applies when the buffer is empty. at any other time, the behaviour should be configurable. + if (code_point == m_termios.c_cc[VEOF] && m_buffer.size() == 0) { finish_edit(); continue; }