From bd68ca362bd5405531c3757f349b40da3e06fc6d Mon Sep 17 00:00:00 2001 From: Paul Berg Date: Sun, 2 May 2021 18:33:31 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibGUI/TextEditor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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(selected_text(), selection); + auto selected = selected_text(); m_selection.clear(); + execute(selected, selection); did_update_selection(); did_change(); set_cursor(selection.start());