LibEdit: Make Ctrl-d on an empty line mean EOD again

This commit is contained in:
Nico Weber 2020-07-07 12:32:37 -04:00 committed by Andreas Kling
parent 8f3151eea8
commit ad8e784938
Notes: sideshowbarker 2024-07-19 05:01:58 +09:00

View file

@ -757,11 +757,22 @@ void Editor::handle_read_event()
m_refresh_needed = true;
continue;
}
// Normally ^D. `stty eof \^n` can change it to ^N (or something else), but Serenity doesn't have `stty` yet.
// Handle it before ctrl shortcuts below and only continue if the buffer is empty, so that the editing shortcuts can take effect else.
if (codepoint == m_termios.c_cc[VEOF] && m_buffer.is_empty()) {
printf("<EOF>\n");
if (!m_always_refresh) {
m_input_error = Error::Eof;
finish();
}
continue;
}
// ^A
if (codepoint == ctrl('A')) {
m_cursor = 0;
continue;
}
// ^B
if (codepoint == ctrl('B')) {
do_cursor_left(Character);
continue;
@ -910,18 +921,6 @@ void Editor::handle_read_event()
}
continue;
}
// Normally ^D
if (codepoint == m_termios.c_cc[VEOF]) {
if (m_buffer.is_empty()) {
printf("<EOF>\n");
if (!m_always_refresh) {
m_input_error = Error::Eof;
finish();
continue;
}
}
continue;
}
if (codepoint == '\n') {
finish();
continue;