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

* fix(extension/sorter): fallbacks to C.name when both exts are the same or nil

* fix(nil): files with no extension

* fix(nil): files with no extension

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
Cyber Oliveira 2023-07-09 00:12:49 -03:00 committed by GitHub
parent 3d2fd90b28
commit 04b2c1e08c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)