Redraw pager on new selection when nothing was selected previously

This commit is contained in:
Simon Börjesson
2023-06-04 19:52:18 +02:00
committed by Peter Ammon
parent c2f58cd312
commit 71c320ca32

View File

@@ -664,8 +664,8 @@ bool pager_t::select_next_completion_in_direction(selection_motion_t direction,
return false;
}
// Handle the case of nothing selected yet.
if (selected_completion_idx == PAGER_SELECTION_NONE) {
// Handle the case of nothing selected yet.
switch (direction) {
case selection_motion_t::south:
case selection_motion_t::page_south:
@@ -679,7 +679,7 @@ bool pager_t::select_next_completion_in_direction(selection_motion_t direction,
} else {
selected_completion_idx = 0;
}
return true;
break;
}
case selection_motion_t::page_north:
case selection_motion_t::east:
@@ -689,8 +689,7 @@ bool pager_t::select_next_completion_in_direction(selection_motion_t direction,
return false;
}
}
}
} else {
// Ok, we had something selected already. Select something different.
size_t new_selected_completion_idx;
if (!selection_direction_is_cardinal(direction)) {
@@ -712,7 +711,8 @@ bool pager_t::select_next_completion_in_direction(selection_motion_t direction,
DIE("unknown non-cardinal direction");
}
} else {
// Cardinal directions. We have a completion index; we wish to compute its row and column.
// Cardinal directions. We have a completion index; we wish to compute its row and
// column.
size_t current_row = this->get_selected_row(rendering);
size_t current_col = this->get_selected_column(rendering);
size_t page_height = std::max(rendering.term_height - 1, static_cast<size_t>(1));
@@ -764,10 +764,11 @@ bool pager_t::select_next_completion_in_direction(selection_motion_t direction,
break;
}
case selection_motion_t::east: {
// Go east, wrapping to the next row. There is no "row memory," so if we run off the
// end, wrap.
// Go east, wrapping to the next row. There is no "row memory," so if we run off
// the end, wrap.
if (current_col + 1 < rendering.cols &&
(current_col + 1) * rendering.rows + current_row < completion_infos.size()) {
(current_col + 1) * rendering.rows + current_row <
completion_infos.size()) {
current_col++;
} else {
current_col = 0;
@@ -802,6 +803,7 @@ bool pager_t::select_next_completion_in_direction(selection_motion_t direction,
return false;
}
selected_completion_idx = new_selected_completion_idx;
}
// Update suggested_row_start to ensure the selection is visible. suggested_row_start *
// rendering.cols is the first suggested visible completion; add the visible completion