Skip to content

Commit b759320

Browse files
committed
fix(pickers): respect default_selection_index
Make sure to move the cursor to the row selected by self:_do_selection() instead of placing it onto the first (or last, depending on the sorting method) line of the picker window. Fixes #3492
1 parent b4da76b commit b759320

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lua/telescope/pickers.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,10 +1466,10 @@ function Picker:get_result_completor(results_bufnr, _, prompt, status_updater)
14661466
if self.sorting_strategy == "descending" then
14671467
local visible_result_rows = vim.api.nvim_win_get_height(self.results_win)
14681468
vim.api.nvim_win_set_cursor(self.results_win, { self.max_results - visible_result_rows, 1 })
1469-
vim.api.nvim_win_set_cursor(self.results_win, { self.max_results, 1 })
1470-
else
1471-
vim.api.nvim_win_set_cursor(self.results_win, { 1, 0 })
14721469
end
1470+
-- Move the cursor back to the row selected in _do_selection()
1471+
local target_pos = { (self._selection_row or 0) + 1, 0 }
1472+
vim.api.nvim_win_set_cursor(self.results_win, target_pos)
14731473
self:_on_complete()
14741474
end)
14751475
end

0 commit comments

Comments
 (0)