TreeView: Don't try to move cursor with invalid index
When clicking on the TreeView in profiler without selecting a node and then pressing up or pgup, cursor_index was in an invalid state. Instead select the first node in the index.
This commit is contained in:
parent
f295ac3c0b
commit
94551149d1
Notes:
sideshowbarker
2024-07-18 16:51:36 +09:00
Author: https://github.com/metmo Commit: https://github.com/SerenityOS/serenity/commit/94551149d1b Pull-request: https://github.com/SerenityOS/serenity/pull/7743 Issue: https://github.com/SerenityOS/serenity/issues/7740 Reviewed-by: https://github.com/gmta
1 changed files with 3 additions and 0 deletions
|
@ -480,6 +480,9 @@ void TreeView::move_cursor(CursorMovement movement, SelectionUpdate selection_up
|
|||
{
|
||||
auto& model = *this->model();
|
||||
|
||||
if (!cursor_index().is_valid())
|
||||
set_cursor(model.index(0, model.tree_column(), cursor_index()), SelectionUpdate::Set);
|
||||
|
||||
auto find_last_index_in_tree = [&](const ModelIndex tree_index) -> ModelIndex {
|
||||
auto last_index = tree_index;
|
||||
size_t row_count = model.row_count(last_index);
|
||||
|
|
Loading…
Add table
Reference in a new issue