chore: resolve undefined-field
This commit is contained in:
@@ -7,7 +7,7 @@ local Watcher = require("nvim-tree.watcher").Watcher
|
|||||||
local Iterator = require("nvim-tree.iterators.node-iterator")
|
local Iterator = require("nvim-tree.iterators.node-iterator")
|
||||||
local DirectoryNode = require("nvim-tree.node.directory")
|
local DirectoryNode = require("nvim-tree.node.directory")
|
||||||
|
|
||||||
---@class GitStatus -- xy short-format statuses
|
---@class (exact) GitStatus -- xy short-format statuses
|
||||||
---@field file string?
|
---@field file string?
|
||||||
---@field dir table<"direct" | "indirect", string[]>?
|
---@field dir table<"direct" | "indirect", string[]>?
|
||||||
|
|
||||||
|
|||||||
@@ -129,44 +129,47 @@ end
|
|||||||
|
|
||||||
---Git file status for an absolute path with optional fallback
|
---Git file status for an absolute path with optional fallback
|
||||||
---@param parent_ignored boolean
|
---@param parent_ignored boolean
|
||||||
---@param status table|nil
|
---@param status table?
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param path_fallback string?
|
---@param path_fallback string?
|
||||||
---@return GitStatus
|
---@return GitStatus
|
||||||
function M.git_status_file(parent_ignored, status, path, path_fallback)
|
function M.git_status_file(parent_ignored, status, path, path_fallback)
|
||||||
|
---@type GitStatus
|
||||||
|
local st = {}
|
||||||
|
|
||||||
if parent_ignored then
|
if parent_ignored then
|
||||||
return { file = "!!" }
|
st.file = "!!"
|
||||||
|
elseif status and status.files then
|
||||||
|
st.file = status.files[path] or status.files[path_fallback]
|
||||||
end
|
end
|
||||||
|
|
||||||
if not status or not status.files then
|
return st
|
||||||
return {}
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
|
||||||
file = status.files[path] or status.files[path_fallback]
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Git file and directory status for an absolute path with optional file fallback
|
---Git file and directory status for an absolute path with optional file fallback
|
||||||
---@param parent_ignored boolean
|
---@param parent_ignored boolean
|
||||||
---@param status table|nil
|
---@param status table?
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param path_file string? alternative file path when no other file status
|
---@param path_file string? alternative file path when no other file status
|
||||||
---@return GitStatus|nil
|
---@return GitStatus?
|
||||||
function M.git_status_dir(parent_ignored, status, path, path_file)
|
function M.git_status_dir(parent_ignored, status, path, path_file)
|
||||||
|
---@type GitStatus?
|
||||||
|
local st
|
||||||
|
|
||||||
if parent_ignored then
|
if parent_ignored then
|
||||||
return { file = "!!" }
|
st = {}
|
||||||
|
st.file = "!!"
|
||||||
|
elseif status then
|
||||||
|
st = {}
|
||||||
|
st.file = status.files and (status.files[path] or status.files[path_file])
|
||||||
|
if status.dirs then
|
||||||
|
st.dir = {}
|
||||||
|
st.dir.direct = status.dirs.direct and status.dirs.direct[path]
|
||||||
|
st.dir.indirect = status.dirs.indirect and status.dirs.indirect[path]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if status then
|
return st
|
||||||
return {
|
|
||||||
file = status.files and (status.files[path] or status.files[path_file]),
|
|
||||||
dir = status.dirs and {
|
|
||||||
direct = status.dirs.direct and status.dirs.direct[path],
|
|
||||||
indirect = status.dirs.indirect and status.dirs.indirect[path],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
|
|||||||
Reference in New Issue
Block a user