Stop duplicate mode names from trapping a plate's mode cycle

The editor only replaced an empty name, so a row could be given a name another
row already had. A plate stores its mode by name and find_imex_mode() takes the
first row with it, so the second row was unreachable, and the plate's mode
list repeated the name: left-click stuck on it, or looped without getting back
to Primary.

An edited name that another row already carries, or the reserved Primary name
in any case, is now replaced when the edit is committed: "copy" becomes
"copy 2". The edited row yields, so plates keep resolving to the row they
meant, and tabbing through a field without changing it checks nothing.
Resetting a row to a saved name that another row has since taken does the
same. The plate's mode list comes from imex_plate_mode_choices(), which lists
each name once, so a profile that already has duplicates still cycles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Clifford Garwood
2026-10-02 23:17:21 -04:00
co-authored by Claude Opus 5.5
parent 8af5fa45e7
commit 9c5f4ebe47
6 changed files with 82 additions and 19 deletions
+8
View File
@@ -1330,6 +1330,14 @@ TEST_CASE("imex_mode_table - every row agrees with find_imex_mode on that name",
}
}
TEST_CASE("A plate offers Primary then each mode name once in table order", "[IMEX]") {
// A profile can carry the same name twice; a plate stores a mode by name, so only the
// first row of a name is reachable, and listing it twice traps the plate's mode cycle.
const DynamicPrintConfig cfg = mode_cfg({ "copy", "mirror", "copy", "", "primary", "iq-copy" }, {}, {});
REQUIRE(imex_plate_mode_choices(cfg) == std::vector<std::string>{ kImexPrimaryMode, "copy", "mirror", "iq-copy" });
REQUIRE(imex_plate_mode_choices(mode_cfg({}, {}, {})) == std::vector<std::string>{ kImexPrimaryMode });
}
// ---------------------------------------------------------------------------
// imex_resolve_routing — the one derivation shared by the hard block and the warning
// ---------------------------------------------------------------------------