From 1e4515947869bf8dffa7f0dab1e018b254b9612b Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 14 Oct 2024 15:59:02 +1100 Subject: [PATCH] fix(#2947): root is never a dotfile, so that it doesn't propagate to children --- lua/nvim-tree/node/init.lua | 7 ++++--- lua/nvim-tree/node/root.lua | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lua/nvim-tree/node/init.lua b/lua/nvim-tree/node/init.lua index d5e78678545..78bbfa6d958 100644 --- a/lua/nvim-tree/node/init.lua +++ b/lua/nvim-tree/node/init.lua @@ -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 @@ -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 diff --git a/lua/nvim-tree/node/root.lua b/lua/nvim-tree/node/root.lua index 4265d49d479..1b236775e70 100644 --- a/lua/nvim-tree/node/root.lua +++ b/lua/nvim-tree/node/root.lua @@ -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