File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change
1
+ local uv = vim .loop
2
+
1
3
local log = require " nvim-tree.log"
2
4
local utils = require " nvim-tree.utils"
3
5
local git_utils = require " nvim-tree.git.utils"
@@ -60,6 +62,10 @@ function M.get_project(project_root)
60
62
end
61
63
62
64
function M .get_project_root (cwd )
65
+ if not M .config .git .enable then
66
+ return nil
67
+ end
68
+
63
69
if M .cwd_to_project_root [cwd ] then
64
70
return M .cwd_to_project_root [cwd ]
65
71
end
@@ -68,11 +74,13 @@ function M.get_project_root(cwd)
68
74
return nil
69
75
end
70
76
71
- if M .config .git .enable then
72
- return git_utils .get_toplevel (cwd )
77
+ local stat , _ = uv .fs_stat (cwd )
78
+ if not stat or stat .type ~= " directory" then
79
+ return nil
73
80
end
74
81
75
- return nil
82
+ M .cwd_to_project_root [cwd ] = git_utils .get_toplevel (cwd )
83
+ return M .cwd_to_project_root [cwd ]
76
84
end
77
85
78
86
local function reload_tree_at (project_root )
You can’t perform that action at this time.
0 commit comments