AbstractTableView: prevent setting an invalid index

If you tried to move a cursor down when the last row is selected, the
index becomes invalid without updating the selection. On the next
cursor movement the invalid index is then reset to {0, 0}, selecting
the first row instead.
This commit is contained in:
Jelle Raaijmakers 2021-01-25 20:37:02 +01:00 committed by Andreas Kling
parent 59396ab1c6
commit d348976784

View file

@ -235,7 +235,9 @@ void AbstractTableView::move_cursor_relative(int vertical_steps, int horizontal_
} else {
new_index = model.index(0, 0);
}
set_cursor(new_index, selection_update);
if (new_index.is_valid()) {
set_cursor(new_index, selection_update);
}
}
void AbstractTableView::scroll_into_view(const ModelIndex& index, bool scroll_horizontally, bool scroll_vertically)