Skip to content

Commit d0518b9

Browse files
committed
fix: sort folds by from value for deterministic output order
pairs() iteration order is non-deterministic across LuaJIT builds, causing the merged fold list order to vary. Sort by from value so the output is always predictable. Also fix the merge test to use was_called_with with the sorted order.
1 parent 999a36d commit d0518b9

2 files changed

Lines changed: 1 addition & 1 deletion

File tree

lua/opencode/ui/renderer/buffer.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ function M.update_part_folds(part_id)
699699
table.insert(new_global, f)
700700
end
701701
end
702+
table.sort(new_global, function(a, b) return a.from < b.from end)
702703
ctx.global_folds = new_global
703704
output_window.set_folds(new_global)
704705
end

tests/unit/renderer_buffer_spec.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ describe('update_part_folds', function()
183183

184184
buffer.update_part_folds('part_a')
185185

186-
assert.stub(set_folds_stub).was_called()
187186
assert.stub(set_folds_stub).was_called_with({
188187
{ from = 5, to = 8 },
189188
{ from = 10, to = 13 },

0 commit comments

Comments
 (0)