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.
This commit is contained in:
Zac 2021-01-25 23:19:07 +10:00 committed by Andreas Kling
parent ed703b461b
commit 94bfde2a38
Notes: sideshowbarker 2024-07-18 22:51:38 +09:00

View file

@ -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 };