mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:25:08 +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
1 changed files with 3 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue