Skip to content

fix: sort_by "extension" falls back to name #2306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lua/nvim-tree/explorer/sorters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,19 @@ function C.extension(a, b)
return false
end

if not (a.extension and b.extension) then
return true
end

if a.extension and not b.extension then
return true
elseif not a.extension and b.extension then
return false
end

return a.extension:lower() <= b.extension:lower()
local a_ext = (a.extension or ""):lower()
local b_ext = (b.extension or ""):lower()
if a_ext == b_ext then
return C.name(a, b)
end

return a_ext < b_ext
end

function C.filetype(a, b)
Expand Down