hotfix: scrolling should work correctly again

This commit is contained in:
Simon Hauser
2022-03-13 20:21:14 +01:00
parent 2532b98d67
commit df303e12e0

View File

@@ -758,10 +758,20 @@ function Picker:get_selection_row()
if self._selection_row then
-- If the current row is no longer selectable than reduce it to num_results - 1, so the next selectable row.
-- This makes selection_strategy `row` work much better if the selected row is no longer part of the output.
--TODO(conni2461): Maybe this can be moved to scroller. (currently in a hotfix so not viable)
if self.selection_strategy == "row" then
local num_results = self.manager:num_results()
if num_results <= self._selection_row then
if self.sorting_strategy == "ascending" then
if self._selection_row >= num_results then
return num_results - 1
end
else
local max = self.max_results - num_results
if self._selection_row < max then
return self.max_results - num_results
end
end
end
return self._selection_row
end
return self.max_results