Skip to content

Commit 04b2c1e

Browse files
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>
1 parent 3d2fd90 commit 04b2c1e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lua/nvim-tree/explorer/sorters.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,19 @@ function C.extension(a, b)
179179
return false
180180
end
181181

182-
if not (a.extension and b.extension) then
183-
return true
184-
end
185-
186182
if a.extension and not b.extension then
187183
return true
188184
elseif not a.extension and b.extension then
189185
return false
190186
end
191187

192-
return a.extension:lower() <= b.extension:lower()
188+
local a_ext = (a.extension or ""):lower()
189+
local b_ext = (b.extension or ""):lower()
190+
if a_ext == b_ext then
191+
return C.name(a, b)
192+
end
193+
194+
return a_ext < b_ext
193195
end
194196

195197
function C.filetype(a, b)

0 commit comments

Comments
 (0)