Skip to content

Commit 80676d7

Browse files
author
Yosef BAYOUDE IZOUKA
committed
Changed method according to maintainer
1 parent 9fa44d5 commit 80676d7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lua/aerial/snacks.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ M.pick_symbol = function(opts)
2323
return
2424
end
2525

26+
local default_selection_index = 1
2627
local bufdata = data.get_or_create(bufnr)
2728
---@type snacks.picker.finder.Item[]
29+
local position = bufdata.positions[bufdata.last_win]
2830
local items = {}
2931
for i, item in bufdata:iter({ skip_hidden = false }) do
3032
local snack_item = {
@@ -38,6 +40,9 @@ M.pick_symbol = function(opts)
3840
if item.parent then
3941
snack_item.parent = items[item.parent.idx]
4042
end
43+
if item == position.closest_symbol then
44+
default_selection_index = ( #items + 1 )
45+
end
4146
table.insert(items, snack_item)
4247
end
4348

@@ -61,9 +66,7 @@ M.pick_symbol = function(opts)
6166
return ret
6267
end,
6368
on_show = function(picker)
64-
local closest_or_exact_symbol = bufdata.positions[bufdata.last_win].exact_symbol or bufdata.positions[bufdata.last_win].closest_symbol
65-
local currentIdx = closest_or_exact_symbol.idx
66-
picker.list.cursor = currentIdx
69+
picker.list.cursor = default_selection_index
6770
end,
6871
}))
6972
end

0 commit comments

Comments
 (0)