Fix single-line statement processing

CURA-12386
The regex was not specific enough and would catch the rest of the line, now we force stopping as soon as we see a { or }
This commit is contained in:
Erwan MATHIEU 2025-02-26 15:02:06 +01:00
parent 5de614590c
commit f9b8bc20c2

View file

@ -76,7 +76,7 @@ class GcodeStartEndFormatter:
# will be used. Alternatively, if the expression is formatted as "{[expression], [extruder_nr]}",
# then the expression will be evaluated with the extruder stack of the specified extruder_nr.
_instruction_regex = re.compile(r"{(?P<condition>if|else|elif|endif)?\s*(?P<expression>.*?)\s*(?:,\s*(?P<extruder_nr_expr>.*))?\s*}(?P<end_of_line>\n?)")
_instruction_regex = re.compile(r"{(?P<condition>if|else|elif|endif)?\s*(?P<expression>[^{}]*?)\s*(?:,\s*(?P<extruder_nr_expr>[^{}]*))?\s*}(?P<end_of_line>\n?)")
def __init__(self, all_extruder_settings: Dict[str, Dict[str, Any]], default_extruder_nr: int = -1) -> None:
super().__init__()