File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1+ local uv = vim .loop
2+
13local log = require " nvim-tree.log"
24local utils = require " nvim-tree.utils"
35local git_utils = require " nvim-tree.git.utils"
@@ -60,6 +62,10 @@ function M.get_project(project_root)
6062end
6163
6264function M .get_project_root (cwd )
65+ if not M .config .git .enable then
66+ return nil
67+ end
68+
6369 if M .cwd_to_project_root [cwd ] then
6470 return M .cwd_to_project_root [cwd ]
6571 end
@@ -68,11 +74,13 @@ function M.get_project_root(cwd)
6874 return nil
6975 end
7076
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
7380 end
7481
75- return nil
82+ M .cwd_to_project_root [cwd ] = git_utils .get_toplevel (cwd )
83+ return M .cwd_to_project_root [cwd ]
7684end
7785
7886local function reload_tree_at (project_root )
You can’t perform that action at this time.
0 commit comments