Skip to content

Commit

Permalink
feat: add focus opt to api.node.open.edit
Browse files Browse the repository at this point in the history
  • Loading branch information
GCrispino committed Jan 27, 2025
1 parent f29521c commit 980a5c1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lua/nvim-tree/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ Api.fs.copy.relative_path = wrap_node(wrap_explorer_member("clipboard", "copy_pa
---
---@class NodeEditOpts
---@field quit_on_open boolean|nil default false
---@field focus boolean|nil default true

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

if edit_opts and edit_opts.quit_on_open then
edit_opts = edit_opts or {}

if edit_opts.quit_on_open then
view.close()
end

local focus = edit_opts.focus == nil or edit_opts.focus == true
if not focus then
view.focus()
end
end

---@param mode string
Expand Down

0 comments on commit 980a5c1

Please sign in to comment.