Skip to content

Commit df534c3

Browse files
authored
fix(git_status): correctly count result on_complete (#3321)
The previous implementation with `self.manager:num_results()` could return 0 despite having results due to suspected async/event loop issues (#3316). This change counts valid entries manually to ensure accurate result count.
1 parent dc6fc32 commit df534c3

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lua/telescope/builtin/__git.lua

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,18 @@ git.status = function(opts)
393393
sorter = conf.file_sorter(opts),
394394
on_complete = {
395395
function(self)
396-
local lines = self.manager:num_results()
397396
local prompt = action_state.get_current_line()
398-
if lines == 0 and prompt == "" then
397+
398+
-- HACK: self.manager:num_results() can return 0 despite having results
399+
-- due to some async/event loop shenanigans (#3316)
400+
local count = 0
401+
for _, entry in pairs(self.finder.results) do
402+
if entry and entry.valid ~= false then
403+
count = count + 1
404+
end
405+
end
406+
407+
if count == 0 and prompt == "" then
399408
utils.notify("builtin.git_status", {
400409
msg = "No changes found",
401410
level = "ERROR",

lua/telescope/make_entry.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ function make_entry.gen_from_git_status(opts)
13871387
return nil
13881388
end
13891389

1390-
return setmetatable({
1390+
return make_entry.set_default_entry_mt({
13911391
value = file,
13921392
status = mod,
13931393
ordinal = entry,

0 commit comments

Comments
 (0)