-
-
Notifications
You must be signed in to change notification settings - Fork 625
feat(#1974): experimental.git.async #2094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d5aefeb
d6940d4
d0f3275
00507f9
6da2a02
7490216
4eb9756
faba33b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,8 +59,9 @@ function M.create_watcher(node) | |
else | ||
log.line("watcher", "node event executing refresh '%s'", node.absolute_path) | ||
end | ||
require("nvim-tree.explorer.reload").refresh_node(node) | ||
require("nvim-tree.renderer").draw() | ||
require("nvim-tree.explorer.reload").refresh_node(node, function() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the last action, hence safe to use a callback. |
||
require("nvim-tree.renderer").draw() | ||
end) | ||
end) | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,21 @@ local WATCHED_FILES = { | |
"index", -- staging area | ||
} | ||
|
||
local function reload_git_status(project_root, path, project, git_status) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved from |
||
if path then | ||
for p in pairs(project.files) do | ||
if p:find(path, 1, true) == 1 then | ||
project.files[p] = nil | ||
end | ||
end | ||
project.files = vim.tbl_deep_extend("force", project.files, git_status) | ||
else | ||
project.files = git_status | ||
end | ||
|
||
project.dirs = git_utils.file_status_to_dir_status(project.files, project_root) | ||
end | ||
|
||
function M.reload() | ||
if not M.config.git.enable then | ||
return {} | ||
|
@@ -34,36 +49,40 @@ function M.reload() | |
return M.projects | ||
end | ||
|
||
function M.reload_project(project_root, path) | ||
function M.reload_project(project_root, path, callback) | ||
local project = M.projects[project_root] | ||
if not project or not M.config.git.enable then | ||
if callback then | ||
callback() | ||
end | ||
return | ||
end | ||
|
||
if path and path:find(project_root, 1, true) ~= 1 then | ||
if callback then | ||
callback() | ||
end | ||
return | ||
end | ||
|
||
local git_status = Runner.run { | ||
local opts = { | ||
project_root = project_root, | ||
path = path, | ||
list_untracked = git_utils.should_show_untracked(project_root), | ||
list_ignored = true, | ||
timeout = M.config.git.timeout, | ||
} | ||
|
||
if path then | ||
for p in pairs(project.files) do | ||
if p:find(path, 1, true) == 1 then | ||
project.files[p] = nil | ||
end | ||
end | ||
project.files = vim.tbl_deep_extend("force", project.files, git_status) | ||
if callback then | ||
Runner.run(opts, function(git_status) | ||
reload_git_status(project_root, path, project, git_status) | ||
callback() | ||
end) | ||
else | ||
project.files = git_status | ||
-- TODO use callback once async/await is available | ||
local git_status = Runner.run(opts) | ||
reload_git_status(project_root, path, project, git_status) | ||
end | ||
|
||
project.dirs = git_utils.file_status_to_dir_status(project.files, project_root) | ||
end | ||
|
||
function M.get_project(project_root) | ||
|
@@ -103,21 +122,22 @@ local function reload_tree_at(project_root) | |
return | ||
end | ||
|
||
M.reload_project(project_root) | ||
local git_status = M.get_project(project_root) | ||
M.reload_project(project_root, nil, function() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Safe to call back as this is the last operation of the watcher. |
||
local git_status = M.get_project(project_root) | ||
|
||
Iterator.builder(root_node.nodes) | ||
:hidden() | ||
:applier(function(node) | ||
local parent_ignored = explorer_node.is_git_ignored(node.parent) | ||
explorer_node.update_git_status(node, parent_ignored, git_status) | ||
end) | ||
:recursor(function(node) | ||
return node.nodes and #node.nodes > 0 and node.nodes | ||
end) | ||
:iterate() | ||
Iterator.builder(root_node.nodes) | ||
:hidden() | ||
:applier(function(node) | ||
local parent_ignored = explorer_node.is_git_ignored(node.parent) | ||
explorer_node.update_git_status(node, parent_ignored, git_status) | ||
end) | ||
:recursor(function(node) | ||
return node.nodes and #node.nodes > 0 and node.nodes | ||
end) | ||
:iterate() | ||
|
||
require("nvim-tree.renderer").draw() | ||
require("nvim-tree.renderer").draw() | ||
end) | ||
end | ||
|
||
function M.load_project_status(cwd) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like gitsigns has stopped (underscore prefixed) experiments.
Using the same pattern as the various lsp plugins.