Skip to content

Commit 15dc00a

Browse files
mtdowlingeuclidianAce
authored andcommitted
Fix sorting bug in directories comparison
The original comparison function had an issue where it would return true immediately when a_str was longer than b_str, without checking the actual string comparison. This led to me getting consistent build failures. The fix properly compares lengths first, then falls back to lexicographic comparison only when lengths are equal.
1 parent 00a172a commit 15dc00a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

build/cyan/commands/build.lua

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cyan/commands/build.tl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,10 @@ local function build(args: command.Args, loaded_config: config.Config, context:
287287
table.sort(unexpected_directories, function(a: lexical_path.Path, b: lexical_path.Path): boolean
288288
local a_str <const> = a:to_string()
289289
local b_str <const> = b:to_string()
290-
if #a_str > #b_str then
291-
return true
290+
local a_len <const> = #a_str
291+
local b_len <const> = #b_str
292+
if a_len ~= b_len then
293+
return a_len > b_len
292294
end
293295
return a_str > b_str
294296
end)

0 commit comments

Comments
 (0)