summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2022-03-13 20:21:14 +0100
committerSimon Hauser <Simon-Hauser@outlook.de>2022-03-13 20:21:14 +0100
commitdf303e12e09b4e6e1fd1e1e184d26827105b318d (patch)
tree6f1ebd27d02bcea8be571758e546b6a615085189
parent2532b98d6747230bb8e55753aa992bea267540a1 (diff)
hotfix: scrolling should work correctly again
-rw-r--r--lua/telescope/pickers.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua
index 9edd9e9..a290bb0 100644
--- a/lua/telescope/pickers.lua
+++ b/lua/telescope/pickers.lua
@@ -758,9 +758,19 @@ 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.
- local num_results = self.manager:num_results()
- if num_results <= self._selection_row then
- return num_results - 1
+ --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 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