Skip to content

Commit fe057aa

Browse files
committed
fix only untracked files not parsing
1 parent f6836b8 commit fe057aa

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

lua/neo-tree/git/init.lua

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ M.status_cache = setmetatable({}, {
4040

4141
---@alias neotree.git.Status table<string, string>
4242

43-
---@param ctx neotree.git.Context
43+
---@param context neotree.git.Context
4444
---@param git_status neotree.git.Status
45-
local update_git_status = function(ctx, git_status)
46-
ctx.git_status = git_status
47-
M.status_cache[ctx.git_root] = git_status
45+
local update_git_status = function(context, git_status)
46+
context.git_status = git_status
47+
M.status_cache[context.git_root] = git_status
4848
vim.schedule(function()
4949
events.fire_event(events.GIT_STATUS_CHANGED, {
50-
git_root = ctx.git_root,
51-
git_status = ctx.git_status,
50+
git_root = context.git_root,
51+
git_status = context.git_status,
5252
})
5353
end)
5454
end
@@ -229,14 +229,19 @@ M._parse_porcelain = function(
229229
else
230230
-- Bubble up the most important status
231231
local p = parent_status:sub(1, 1)
232+
local bubbled = false
232233
for _, c in ipairs(status_prio) do
233234
if p == c then
234235
break
235236
end
236237
if s1 == c or s2 == c then
237238
git_status[parent] = c
239+
bubbled = true
238240
end
239241
end
242+
if not bubbled then
243+
break
244+
end
240245
end
241246
end
242247
end
@@ -362,13 +367,14 @@ local async_git_status_job = function(context, git_args, callback)
362367
return
363368
end
364369

365-
if #output_chunks == 0 then
366-
return
367-
end
368370
local output = output_chunks[1]
369371
if #output_chunks > 1 then
370372
output = table.concat(output_chunks, "")
371373
end
374+
if not output then
375+
callback(context.git_status)
376+
return
377+
end
372378

373379
---@diagnostic disable-next-line: param-type-mismatch
374380
local status_iter = vim.gsplit(output, "\000", gsplit_plain)
@@ -383,7 +389,6 @@ local async_git_status_job = function(context, git_args, callback)
383389
context.batch_size
384390
)
385391
)
386-
387392
local processed_lines = 0
388393
local function do_next_batch_later()
389394
if co.status(parsing_task) ~= "dead" then
@@ -442,7 +447,13 @@ M.status_async = function(path, base, opts)
442447
-- do a fast scan first to get basic things in, then a full scan with ignore/untracked files
443448
async_git_status_job(
444449
ctx,
445-
make_git_status_args(M._supported_porcelain_version, git_root, "no", "no", { path }),
450+
make_git_status_args(
451+
M._supported_porcelain_version,
452+
git_root,
453+
"no",
454+
"traditional",
455+
{ path }
456+
),
446457
function(fast_status)
447458
update_git_status(ctx, fast_status)
448459
async_git_status_job(ctx, nil, function(full_status)

0 commit comments

Comments
 (0)