Skip to content

Commit 1c8b343

Browse files
committed
chore: resolve undefined-field
1 parent 4aba93b commit 1c8b343

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

lua/nvim-tree/git/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ local DirectoryNode = require("nvim-tree.node.directory")
1818

1919
---Git short-format statuses for a single node
2020
---@class (exact) GitNodeStatus
21-
---@field file GitXY
21+
---@field file GitXY?
2222
---@field dir table<"direct" | "indirect", GitXY[]>?
2323

2424
---Git state for an entire repo

lua/nvim-tree/git/utils.lua

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,18 @@ end
138138
---@return GitNodeStatus
139139
function M.git_status_file(parent_ignored, status, path, path_fallback)
140140
---@type GitNodeStatus
141-
local ns = {}
141+
local ns
142142

143143
if parent_ignored then
144-
ns.file = "!!"
144+
ns = {
145+
file = "!!"
146+
}
145147
elseif status and status.files then
146-
ns.file = status.files[path] or status.files[path_fallback]
148+
ns = {
149+
file = status.files[path] or status.files[path_fallback]
150+
}
151+
else
152+
ns = {}
147153
end
148154

149155
return ns
@@ -160,16 +166,17 @@ function M.git_status_dir(parent_ignored, status, path, path_fallback)
160166
local ns
161167

162168
if parent_ignored then
163-
ns = {}
164-
ns.file = "!!"
169+
ns = {
170+
file = "!!"
171+
}
165172
elseif status then
166-
ns = {}
167-
ns.file = status.files and (status.files[path] or status.files[path_fallback])
168-
if status.dirs then
169-
ns.dir = {}
170-
ns.dir.direct = status.dirs.direct and status.dirs.direct[path]
171-
ns.dir.indirect = status.dirs.indirect and status.dirs.indirect[path]
172-
end
173+
ns = {
174+
file = status.files and (status.files[path] or status.files[path_fallback]),
175+
dir = status.dirs and {
176+
direct = status.dirs.direct and status.dirs.direct[path],
177+
indirect = status.dirs.indirect and status.dirs.indirect[path],
178+
},
179+
}
173180
end
174181

175182
return ns

0 commit comments

Comments
 (0)