@@ -124,12 +124,38 @@ function M.node_comparator_modification_time(a, b)
|
||||
return last_modified_b <= last_modified_a
|
||||
end
|
||||
|
||||
function M.node_comparator_extension(a, b)
|
||||
if not (a and b) then
|
||||
return true
|
||||
end
|
||||
|
||||
if a.nodes and not b.nodes then
|
||||
return true
|
||||
elseif not a.nodes and b.nodes then
|
||||
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()
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
M.sort_by = opts.sort_by
|
||||
if M.sort_by == "modification_time" then
|
||||
M.node_comparator = M.node_comparator_modification_time
|
||||
elseif M.sort_by == "case_sensitive" then
|
||||
M.node_comparator = M.node_comparator_name_case_sensisive
|
||||
elseif M.sort_by == "extension" then
|
||||
M.node_comparator = M.node_comparator_extension
|
||||
else
|
||||
M.node_comparator = M.node_comparator_name_ignorecase
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user