summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/config.lua1
-rw-r--r--lua/telescope/finders.lua2
-rw-r--r--lua/telescope/pickers.lua25
3 files changed, 21 insertions, 7 deletions
diff --git a/lua/telescope/config.lua b/lua/telescope/config.lua
index 5be5b7c..5effd2f 100644
--- a/lua/telescope/config.lua
+++ b/lua/telescope/config.lua
@@ -34,6 +34,7 @@ function config.set_defaults(defaults)
set("sorting_strategy", "descending")
set("selection_strategy", "reset")
+ set("scroll_strategy", nil)
set("layout_strategy", "horizontal")
set("layout_defaults", {})
diff --git a/lua/telescope/finders.lua b/lua/telescope/finders.lua
index a3ca097..b2c20e8 100644
--- a/lua/telescope/finders.lua
+++ b/lua/telescope/finders.lua
@@ -178,8 +178,6 @@ function OneshotJobFinder:new(opts)
finder, _, process_result, process_complete = coroutine.yield()
num_execution = num_execution + 1
- log.debug("Using previous results", job.is_shutdown, completed, num_execution)
-
local current_count = num_results
for index = 1, current_count do
process_result(results[index])
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua
index 8d31686..bbc2e2c 100644
--- a/lua/telescope/pickers.lua
+++ b/lua/telescope/pickers.lua
@@ -83,6 +83,7 @@ function Picker:new(opts)
sorting_strategy = get_default(opts.sorting_strategy, config.values.sorting_strategy),
selection_strategy = get_default(opts.selection_strategy, config.values.selection_strategy),
+ scroll_strategy = get_default(opts.scroll_strategy, config.values.scroll_strategy),
get_window_options = opts.get_window_options,
layout_strategy = layout_strategy,
@@ -639,14 +640,28 @@ function Picker:reset_selection()
self.multi_select = {}
end
+function Picker:_handle_scroll_strategy(row)
+ if self.scroll_strategy == "cycle" then
+ if row >= self.max_results then
+ row = 0
+ elseif row < 0 then
+ row = self.max_results - 1
+ end
+ else
+ if row >= self.max_results then
+ row = self.max_results - 1
+ elseif row < 0 then
+ row = 0
+ end
+ end
+
+ return row
+end
+
function Picker:set_selection(row)
-- TODO: Loop around behavior?
-- TODO: Scrolling past max results
- if row >= self.max_results then
- row = self.max_results - 1
- elseif row < 0 then
- row = 0
- end
+ row = self:_handle_scroll_strategy(row)
if not self:can_select_row(row) then
log.debug("Cannot select row:", row, self.manager:num_results(), self.max_results)