Skip to content

Commit c30fcb6

Browse files
authored
fix(actions): handle entries with no stat in sorting (#163)
1 parent d5c37ae commit c30fcb6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lua/telescope/_extensions/file_browser/actions.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,12 @@ fb_actions.sort_by_size = function(prompt_bufnr)
661661
local finder = action_state.get_current_picker(prompt_bufnr).finder
662662
finder.__sort_size = not finder.__sort_size
663663
sort_by(prompt_bufnr, function(x, y)
664+
if not x.stat then
665+
return false
666+
end
667+
if not y.stat then
668+
return true
669+
end
664670
if x.stat.size > y.stat.size then
665671
return finder.__sort_size
666672
elseif x.stat.size < y.stat.size then
@@ -678,6 +684,12 @@ fb_actions.sort_by_date = function(prompt_bufnr)
678684
local finder = action_state.get_current_picker(prompt_bufnr).finder
679685
finder.__sort_date = not finder.__sort_date
680686
sort_by(prompt_bufnr, function(x, y)
687+
if not x.stat then
688+
return false
689+
end
690+
if not y.stat then
691+
return true
692+
end
681693
if x.stat.mtime.sec > y.stat.mtime.sec then
682694
return finder.__sort_date
683695
elseif x.stat.mtime.sec < y.stat.mtime.sec then

0 commit comments

Comments
 (0)