feat(#2305): find file refreshes up the tree when node is not present (#2358)

This commit is contained in:
Alexander Courtis
2023-08-14 11:08:16 +10:00
committed by GitHub
parent 116b88564f
commit ace64228ad
2 changed files with 45 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ local log = require "nvim-tree.log"
local view = require "nvim-tree.view"
local utils = require "nvim-tree.utils"
local renderer = require "nvim-tree.renderer"
local reload = require "nvim-tree.explorer.reload"
local core = require "nvim-tree.core"
local Iterator = require "nvim-tree.iterators.node-iterator"
@@ -29,8 +30,10 @@ function M.fn(path)
local profile = log.profile_start("find file %s", path_real)
-- force a re-expand when the node is not in the tree
local node_present = utils.get_node_from_path(path_real) ~= nil
-- refresh the contents of all parents, expanding groups as needed
if utils.get_node_from_path(path_real) == nil then
reload.refresh_parent_nodes_for_path(vim.fn.fnamemodify(path_real, ":h"))
end
local line = core.get_nodes_starting_line()
@@ -57,7 +60,7 @@ function M.fn(path)
if not node.group_next then
node.open = true
end
if #node.nodes == 0 or not node_present then
if #node.nodes == 0 then
core.get_explorer():expand(node)
end
end