fix: find file waits for git to finish (#976)

This commit is contained in:
Kiyan
2022-02-15 08:22:56 +01:00
committed by GitHub
parent 1a5ee2870e
commit d34ea42254

View File

@@ -6,18 +6,19 @@ local renderer = require"nvim-tree.renderer"
local M = {}
function M.fn(fname)
local i
local function get_index_offset()
local hide_root_folder = view.View.hide_root_folder
if not TreeExplorer then
return
end
if TreeExplorer.cwd == '/' or hide_root_folder then
i = 0
return 0
else
i = 1
return 1
end
end
function M.fn(fname)
if not TreeExplorer then return end
local i = get_index_offset()
local tree_altered = false
local function iterate_nodes(nodes)
@@ -27,26 +28,27 @@ function M.fn(fname)
return i
end
local path_matches = utils.str_find(fname, node.absolute_path..utils.path_separator)
local path_matches = node.nodes and utils.str_find(fname, node.absolute_path..utils.path_separator)
if path_matches then
if #node.nodes == 0 then
node.open = true
explorer_module.explore(node, node.absolute_path, {})
git.load_project_status(node.absolute_path, function(status)
if status.dirs or status.files then
require"nvim-tree.actions.reloaders".reload_node_status(node, git.projects)
end
renderer.draw()
end)
end
if node.open == false then
if not node.open then
node.open = true
tree_altered = true
end
if #node.nodes == 0 then
local git_finished = false
git.load_project_status(node.absolute_path, function(status)
explorer_module.explore(node, node.absolute_path, status)
git_finished = true
end)
while not vim.wait(10, function() return git_finished end, 10) do end
end
if iterate_nodes(node.nodes) ~= nil then
return i
end
elseif node.open == true then
-- mandatory to iterate i
elseif node.open then
iterate_nodes(node.nodes)
end
end