summaryrefslogtreecommitdiff
path: root/lua/telescope/pickers.lua
diff options
context:
space:
mode:
authorTom <tapayne88@users.noreply.github.com>2021-07-02 11:42:25 +0100
committerGitHub <noreply@github.com>2021-07-02 12:42:25 +0200
commitc5a6ed16e2022e2d19936e00a8a39a97cba39f11 (patch)
tree06ef437e6c5f5c7025dc49d7c6eba4df2b56c91f /lua/telescope/pickers.lua
parent50001d4965af3c95614b1423ab6d130068319cd9 (diff)
feat: `selection_strategy` closest (#885)
* Added closest selection_strategy to use default_selection_index initially but prefer highest ranked match when prompt not empty * Updated supporting documentation to include selection_strategy
Diffstat (limited to 'lua/telescope/pickers.lua')
-rw-r--r--lua/telescope/pickers.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua
index f8a0eea..e4c73e2 100644
--- a/lua/telescope/pickers.lua
+++ b/lua/telescope/pickers.lua
@@ -1069,6 +1069,12 @@ function Picker:get_result_completor(results_bufnr, find_id, prompt, status_upda
else
self:set_selection(self:get_reset_row())
end
+ elseif selection_strategy == 'closest' then
+ if prompt == "" and self.default_selection_index ~= nil then
+ self:set_selection(self:get_row(self.default_selection_index))
+ else
+ self:set_selection(self:get_reset_row())
+ end
else
error('Unknown selection strategy: ' .. selection_strategy)
end