mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +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
Notes:
sideshowbarker
2024-07-18 22:51:50 +09:00
Author: https://github.com/gmta 🔰
Commit: d348976784
Pull-request: https://github.com/SerenityOS/serenity/pull/5112
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