From 94bfde2a3851e5d6ac09c2f4848b0336dcf91271 Mon Sep 17 00:00:00 2001 From: Zac Date: Mon, 25 Jan 2021 23:19:07 +1000 Subject: [PATCH] TextEditor: Fix bug in delete_current_line() when deleting the last line A missing '- 1' when initializing the starting TextPosition lead to a crash due to attempting to delete text in an illegal TextRange. --- Userland/Libraries/LibGUI/TextEditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 3798a50c5b..d4b916b994 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -770,7 +770,7 @@ void TextEditor::delete_current_line() start = { 0, 0 }; end = { 0, line(0).length() }; } else if (m_cursor.line() == line_count() - 1) { - start = { m_cursor.line() - 1, line(m_cursor.line()).length() }; + start = { m_cursor.line() - 1, line(m_cursor.line() - 1).length() }; end = { m_cursor.line(), line(m_cursor.line()).length() }; } else { start = { m_cursor.line(), 0 };