Skip to content

Commit 14102dc

Browse files
authored
fix: navigate to symbol with Snacks in scratch buf (#499)
* fix: navigate to symbol with Snacks in scratch buf * chore: add line spacing --------- Co-authored-by: Oli Morris <[email protected]>
1 parent 8bb8697 commit 14102dc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lua/aerial/snacks.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ local backends = require("aerial.backends")
22
local config = require("aerial.config")
33
local data = require("aerial.data")
44
local highlight = require("aerial.highlight")
5+
local navigation = require("aerial.navigation")
6+
57
local M = {}
68
---@module 'snacks.picker'
79

810
---@param opts? snacks.picker.Config
911
M.pick_symbol = function(opts)
12+
local winid = vim.api.nvim_get_current_win()
1013
local bufnr = vim.api.nvim_get_current_buf()
1114
local filename = vim.api.nvim_buf_get_name(bufnr)
1215
local backend = backends.get()
@@ -49,7 +52,7 @@ M.pick_symbol = function(opts)
4952
last[parent] = snack_item
5053
snack_item.last = true
5154
end
52-
if item == position.closest_symbol then
55+
if position and item == position.closest_symbol then
5356
default_selection_index = (#items + 1)
5457
end
5558
table.insert(items, snack_item)
@@ -61,6 +64,12 @@ M.pick_symbol = function(opts)
6164
sort = {
6265
fields = { "idx" },
6366
},
67+
actions = {
68+
confirm = function(picker, item)
69+
picker:close()
70+
navigation.select_symbol(item.item, winid, bufnr, { jump = true })
71+
end,
72+
},
6473
format = function(item, picker)
6574
---@type aerial.Symbol
6675
local symbol = item.item

0 commit comments

Comments
 (0)