diff options
author | Paul Berg <paul.berg@etu.utc.fr> | 2021-05-02 18:33:31 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-03 08:45:32 +0200 |
commit | bd68ca362bd5405531c3757f349b40da3e06fc6d (patch) | |
tree | 6bc1c2c0a93ec84783efe152dc5e8e357e885110 /Userland/Libraries/LibGUI/TextEditor.cpp | |
parent | 97d00280982c7ea51ada6a4a4068cb23eb9c9097 (diff) | |
download | serenity-bd68ca362bd5405531c3757f349b40da3e06fc6d.zip |
TextEditor: Clear the selection before deleting it
This patches fixes a crash of the Userland/TextEditor where it would
crash when deleting a range spanning two lines. This was because the
TextEditor would delete the range and modify the cursor position
before clearing the selection. This would trigger a status bar update
with the invalid selection.
Diffstat (limited to 'Userland/Libraries/LibGUI/TextEditor.cpp')
-rw-r--r-- | Userland/Libraries/LibGUI/TextEditor.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 68dff0002e..1e6256ec1b 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -1220,8 +1220,9 @@ String TextEditor::selected_text() const void TextEditor::delete_selection() { auto selection = normalized_selection(); - execute<RemoveTextCommand>(selected_text(), selection); + auto selected = selected_text(); m_selection.clear(); + execute<RemoveTextCommand>(selected, selection); did_update_selection(); did_change(); set_cursor(selection.start()); |