From 415da86d391b553e728c9a24ff6fde9622668f73 Mon Sep 17 00:00:00 2001 From: MarekSpodBiedry <73122968+MarekSpodBiedry@users.noreply.github.com> Date: Sat, 10 Oct 2026 18:57:42 +0200 Subject: [PATCH] Scripts: split a line at keyword prompts so POLYGON 6 200,20 I 15 works (#43) (#45) --- crates/engine/src/lib.rs | 3 ++- crates/engine/src/tests.rs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 71b7c736a..4f7023198 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -809,7 +809,8 @@ impl Session { } let mut rest = line; loop { - let text_prompt = self.current_prompt().is_some_and(|p| p.accept.text && !p.accept.point); + // Free text only when the prompt has no keywords; otherwise split so `I 15` reaches the keyword and the value. + let text_prompt = self.current_prompt().is_some_and(|p| p.accept.text && !p.accept.point && p.keywords.is_empty()); if text_prompt || self.running.is_none() && rest.contains('{') { self.cmdline(rest)?; break; diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 3688c757f..0abd994ab 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -460,6 +460,13 @@ fn script_runs_commands() { assert!(matches!(&t.kind, EntityKind::Text(t) if t.value == "Hello world")); } +#[test] +fn script_splits_line_at_keyword_prompt() { + let mut s = Session::new(); + s.script("POLYGON 6 200,20 I 15").unwrap(); + assert_eq!(kinds(&s), vec!["Polyline"]); +} + #[test] fn enter_repeats_last_command() { let mut s = Session::new();