Skip to content

fix(#2947): root is never a dotfile, so that it doesn't propagate to children #2958

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

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading