Skip to content

Commit 980a5c1

Browse files
committed
feat: add focus opt to api.node.open.edit
1 parent f29521c commit 980a5c1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lua/nvim-tree/api.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ Api.fs.copy.relative_path = wrap_node(wrap_explorer_member("clipboard", "copy_pa
225225
---
226226
---@class NodeEditOpts
227227
---@field quit_on_open boolean|nil default false
228+
---@field focus boolean|nil default true
228229

229230
---@param mode string
230231
---@param node Node
@@ -234,9 +235,16 @@ local function edit(mode, node, edit_opts)
234235
local path = file_link and file_link.link_to or node.absolute_path
235236
actions.node.open_file.fn(mode, path)
236237

237-
if edit_opts and edit_opts.quit_on_open then
238+
edit_opts = edit_opts or {}
239+
240+
if edit_opts.quit_on_open then
238241
view.close()
239242
end
243+
244+
local focus = edit_opts.focus == nil or edit_opts.focus == true
245+
if not focus then
246+
view.focus()
247+
end
240248
end
241249

242250
---@param mode string

0 commit comments

Comments
 (0)