Преглед на файлове

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.
Zac преди 4 години
родител
ревизия
94bfde2a38
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  1. 1 1
      Userland/Libraries/LibGUI/TextEditor.cpp

+ 1 - 1
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 };