Skip to content

Commit

Permalink
fix(#2947): root is never a dotfile, so that it doesn't propagate to …
Browse files Browse the repository at this point in the history
…children (#2958)
  • Loading branch information
alex-courtis authored Oct 14, 2024
1 parent ce09bfb commit f5f6789
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/nvim-tree/node/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ local git = require("nvim-tree.git")
---@field fs_stat uv.fs_stat.result?
---@field git_status GitStatus?
---@field hidden boolean
---@field is_dot boolean
---@field name string
---@field parent Node?
---@field watcher Watcher?
---@field diag_status DiagStatus?
---@field is_dot boolean cached is_dotfile
local BaseNode = {}

---@alias Node RootNode|BaseNode|DirectoryNode|FileNode|LinkNode
Expand Down Expand Up @@ -157,11 +157,12 @@ function BaseNode:is_git_ignored()
return self.git_status ~= nil and self.git_status.file == "!!"
end

---Node or one of its parents begins with a dot
---@return boolean
function BaseNode:is_dotfile()
if
self.is_dot --
or (self.name and (self.name:sub(1, 1) == ".")) --
self.is_dot
or (self.name and (self.name:sub(1, 1) == "."))
or (self.parent and self.parent:is_dotfile())
then
self.is_dot = true
Expand Down
6 changes: 6 additions & 0 deletions lua/nvim-tree/node/root.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ function RootNode:create(explorer, absolute_path, name, fs_stat)
return o
end

---Root is never a dotfile
---@return boolean
function RootNode:is_dotfile()
return false
end

return RootNode

0 comments on commit f5f6789

Please sign in to comment.