Skip to content

Commit 8f6d104

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 8f6d104

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lua/telescope/pickers.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,10 +1466,9 @@ 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+
vim.api.nvim_win_set_cursor(self.results_win, { self._selection_row + 1, 0 })
14731472
self:_on_complete()
14741473
end)
14751474
end

0 commit comments

Comments
 (0)