[listview] set_selection() wasn't checking if the view was selectable

Fixes #1263
This commit is contained in:
Tim Stack 2024-05-17 08:42:16 -07:00
parent f9c49712c6
commit 4fd6b62380

View File

@ -45,7 +45,11 @@ using namespace std::chrono_literals;
list_gutter_source listview_curses::DEFAULT_GUTTER_SOURCE; list_gutter_source listview_curses::DEFAULT_GUTTER_SOURCE;
listview_curses::listview_curses() : lv_scroll(noop_func{}) {} listview_curses::
listview_curses()
: lv_scroll(noop_func{})
{
}
bool bool
listview_curses::contains(int x, int y) const listview_curses::contains(int x, int y) const
@ -1109,6 +1113,13 @@ listview_curses::set_selection_without_context(vis_line_t sel)
void void
listview_curses::set_selection(vis_line_t sel) listview_curses::set_selection(vis_line_t sel)
{ {
if (!this->lv_selectable) {
if (sel >= 0_vl) {
this->set_top(sel);
}
return;
}
auto dim = this->get_dimensions(); auto dim = this->get_dimensions();
auto diff = std::optional<vis_line_t>{}; auto diff = std::optional<vis_line_t>{};