GTextEditor: Fix double effect of backspace/delete in some cases.

This commit is contained in:
Andreas Kling 2019-03-07 17:18:22 +01:00
parent a738b5cb69
commit f13c62f225
Notes: sideshowbarker 2024-07-19 15:08:06 +09:00

View File

@ -213,6 +213,7 @@ void GTextEditor::keydown_event(GKeyEvent& event)
current_line().remove(m_cursor.column() - 1);
update_scrollbar_ranges();
set_cursor(m_cursor.line(), m_cursor.column() - 1);
return;
}
if (m_cursor.column() == 0 && m_cursor.line() != 0) {
// Backspace at column 0; merge with previous line
@ -223,6 +224,7 @@ void GTextEditor::keydown_event(GKeyEvent& event)
update_scrollbar_ranges();
update();
set_cursor(m_cursor.line() - 1, previous_length);
return;
}
return;
}
@ -233,6 +235,7 @@ void GTextEditor::keydown_event(GKeyEvent& event)
current_line().remove(m_cursor.column());
update_scrollbar_ranges();
update_cursor();
return;
}
if (m_cursor.column() == (current_line().length() + 1) && m_cursor.line() != line_count() - 1) {
// Delete at end of line; merge with next line
@ -243,6 +246,7 @@ void GTextEditor::keydown_event(GKeyEvent& event)
update_scrollbar_ranges();
update();
set_cursor(m_cursor.line(), previous_length);
return;
}
return;
}