Skip to content

Commit 7a269ae

Browse files
committed
fix(weighted-score): place weight editor after score
1 parent 08333e2 commit 7a269ae

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎spec/System/TestWeightedScore_spec.lua‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,19 +386,19 @@ describe("WeightedScore — tree integration", function()
386386
assert.is_false(called)
387387
end)
388388

389-
it("appendEditWeightsAction inserts an action before WeightedScore", function()
389+
it("appendEditWeightsAction appends an action after WeightedScore", function()
390390
local list = {
391391
{ label = "Sort by Name", sortMode = "name" },
392392
{ label = "Sort by Weighted Score", sortMode = "WeightedScore", isWeightedScore = true },
393393
}
394394
local opened = false
395395
WeightedScore.appendEditWeightsAction(list, function() opened = true end)
396396
assert.are.equal(3, #list)
397-
local entry = list[2]
397+
local entry = list[3]
398398
assert.is_true(entry.isAction)
399399
assert.is_function(entry.action)
400400
assert.is_string(entry.label)
401-
assert.is_true(list[3].isWeightedScore)
401+
assert.is_true(list[2].isWeightedScore)
402402
entry.action()
403403
assert.is_true(opened, "calling entry.action must invoke the openEditor callback")
404404
end)

‎src/Modules/WeightedScore.lua‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ function WeightedScore.computeRatioScore(baseOutput, newOutput, weights)
7878
return meanStatDiff
7979
end
8080

81-
-- Insert a contextual "Edit Weights..." action immediately before WeightedScore
82-
-- so the score remains the final metric in every compatible sort dropdown.
81+
-- Append a contextual "Edit Weights..." action after WeightedScore so the
82+
-- score remains the final metric while its configuration stays adjacent.
8383
function WeightedScore.appendEditWeightsAction(sortDropList, openEditor)
84-
for index, entry in ipairs(sortDropList) do
84+
for _, entry in ipairs(sortDropList) do
8585
if entry.isWeightedScore then
86-
table.insert(sortDropList, index, {
86+
table.insert(sortDropList, {
8787
label = colorCodes.TIP .. "Edit Weights...",
8888
isAction = true,
8989
action = openEditor,

0 commit comments

Comments
 (0)