mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
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:
parent
59396ab1c6
commit
d348976784
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue