Fix wrong multi-variant category displayed in unsaved cfg dialog if option name is a prefix of another option

(such as `filament_wipe` and `filament_wipe_distance`)
This commit is contained in:
Noisyfox
2026-05-22 10:46:29 +08:00
parent 6690bdf149
commit a5453acdc5
2 changed files with 5 additions and 4 deletions

View File

@@ -8257,7 +8257,7 @@ std::set<std::string> filament_options_with_variant = {
"filament_deretraction_speed",
"filament_retraction_minimum_travel",
"filament_retract_when_changing_layer",
"filament_wipe",
"filament_wipe",
//BBS
"filament_wipe_distance",
"filament_retract_before_wipe",

View File

@@ -346,14 +346,15 @@ const Option &OptionsSearcher::get_option(const std::string &opt_key, Preset::Ty
if (it->opt_key() == opt_key2) {
variant_index = -1;
} else {
it = std::lower_bound(it, options.end(), Option({boost::nowide::widen(get_key(opt_key2 + "#", type))}));
if (it == options.end() || it->opt_key().compare(0, opt_key2.length(), opt_key2) != 0) {
const std::string opt_key3 = opt_key2 + "#";
it = std::lower_bound(it, options.end(), Option({boost::nowide::widen(get_key(opt_key3, type))}));
if (it == options.end() || it->opt_key().compare(0, opt_key3.length(), opt_key3) != 0) {
variant_index = -2; // Not found
return options[0];
}
auto it2 = it;
++it2;
if (it2 != options.end() && it2->opt_key().compare(0, opt_key2.length(), opt_key2) == 0
if (it2 != options.end() && it2->opt_key().compare(0, opt_key3.length(), opt_key3) == 0
&& printer_options_with_variant_1.find(opt_key2) == printer_options_with_variant_1.end())
variant_index = -2;
}