Skip to content

Commit 92d1dc3

Browse files
cavanaugdlyongemallo
authored andcommitted
fix(hg): guard against missing file_info entry for unresolved files
Initialise the file_info entry before setting status when the file state is 'u' (unresolved), preventing a nil index error in tracked_files(). Cherry-picked from cavanaug/diffview.nvim (commit 2711fc7).
1 parent d36effe commit 92d1dc3

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lua/diffview/vcs/adapters/hg/init.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,14 @@ HgAdapter.tracked_files = async.wrap(function (self, left, right, args, kind, op
11401140
end
11411141
end
11421142
if file.state == 'u' then
1143+
-- Ensure file_info entry exists before accessing it
1144+
if not file_info[file.path] then
1145+
file_info[file.path] = {
1146+
status = "",
1147+
name = file.path,
1148+
stats = {},
1149+
}
1150+
end
11431151
file_info[file.path].status = 'U'
11441152
file_info[file.path].base = base
11451153
if file.other_path ~= file.path then

0 commit comments

Comments
 (0)