File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff 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 }))
6972end
You can’t perform that action at this time.
0 commit comments