diff options
author | networkException <git@nwex.de> | 2022-07-10 12:02:19 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-07-10 12:20:02 +0200 |
commit | 710fb11c730fd38d748e6b2396353a040389b71c (patch) | |
tree | fb5d42239a723c076db6b62051163cf97fc69ea3 /Userland/Libraries | |
parent | 071b92e920f49783973619f8edd8877b6754d75f (diff) | |
download | serenity-710fb11c730fd38d748e6b2396353a040389b71c.zip |
LibGUI: Allow deleting text editor indent selections in non tab cases
Since 00f51d42d2aeb44ec4813ca13be787c2f5ca55ff we would not allow the
deletion for a selection by typing if it would match the conditions to
indent on pressing tab.
As any single line TextEditor would always match the indent conditions,
it was impossible to replace selected text by typing in a TextBox,
PasswordBox or UrlBox.
A missing return, as pointed out in https://github.com/SerenityOS/serenity/pull/13269#discussion_r900866416
was the cause for the additional checks in
TextEditor::insert_at_cursor_or_replace_selection, described in https://github.com/SerenityOS/serenity/pull/13269#discussion_r901009457
With the early return in place the additional checks are not aiding with
the indented behavior but cause the regression described above.
This patch removes the unnecessary conditions.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/TextEditor.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 698935fe75..f678ae95ee 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -1501,7 +1501,7 @@ void TextEditor::insert_at_cursor_or_replace_selection(StringView text) { ReflowDeferrer defer(*this); VERIFY(is_editable()); - if (has_selection() && !is_indenting_selection()) + if (has_selection()) delete_selection(); // Check if adding a newline leaves the previous line as just whitespace. @@ -1510,8 +1510,7 @@ void TextEditor::insert_at_cursor_or_replace_selection(StringView text) && clear_length > 0 && current_line().leading_spaces() == clear_length; - if (!is_indenting_selection()) - execute<InsertTextCommand>(text, m_cursor); + execute<InsertTextCommand>(text, m_cursor); if (should_clear_last_line) { // If it does leave just whitespace, clear it. auto const original_cursor_position = cursor(); |