From 0e18201b7ea1d583ebb7669da88fc11d91e7d740 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 23 Jun 2019 07:53:58 +0200 Subject: [PATCH] GTextEditor: Don't replace selection on enter press in single-line editor. --- LibGUI/GTextEditor.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/LibGUI/GTextEditor.cpp b/LibGUI/GTextEditor.cpp index 660d457236..7122d25c74 100644 --- a/LibGUI/GTextEditor.cpp +++ b/LibGUI/GTextEditor.cpp @@ -359,6 +359,12 @@ void GTextEditor::keydown_event(GKeyEvent& event) if (is_single_line() && event.key() == KeyCode::Key_Tab) return GWidget::keydown_event(event); + if (is_single_line() && event.key() == KeyCode::Key_Return) { + if (on_return_pressed) + on_return_pressed(); + return; + } + if (event.key() == KeyCode::Key_Escape) { if (on_escape_pressed) on_escape_pressed(); @@ -600,11 +606,6 @@ void GTextEditor::insert_at_cursor(char ch) bool at_head = m_cursor.column() == 0; bool at_tail = m_cursor.column() == current_line().length(); if (ch == '\n') { - if (is_single_line()) { - if (on_return_pressed) - on_return_pressed(); - return; - } if (at_tail || at_head) { String new_line_contents; if (m_automatic_indentation_enabled && at_tail) {