Scripts: split a line at keyword prompts so POLYGON 6 200,20 I 15 works (#43) (#45)

This commit is contained in:
MarekSpodBiedry
2026-10-10 12:57:42 -04:00
committed by GitHub
parent 8995fb9174
commit 415da86d39
2 changed files with 9 additions and 1 deletions
+2 -1
View File
@@ -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;
+7
View File
@@ -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();