From 62a67464593e09ae0241bcd0fa21271751d44957 Mon Sep 17 00:00:00 2001 From: aiirvizionz Date: Sat, 18 Jul 2026 16:42:54 -0600 Subject: [PATCH] fix(tui): preserve quoted Windows paths --- src/tui.mjs | 10 +++++++++- test/tui.test.mjs | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/tui.mjs b/src/tui.mjs index 289629f..1eb4af3 100644 --- a/src/tui.mjs +++ b/src/tui.mjs @@ -66,12 +66,20 @@ const ask = (rl) => new Promise((res) => rl.question(PROMPT(), res)); export function splitCommandLine(line) { const parts = []; let value = "", quote = null, escaped = false, started = false; - for (const char of String(line)) { + const input = String(line); + for (let i = 0; i < input.length; i++) { + const char = input[i]; if (escaped) { value += char; escaped = false; started = true; } else if (char === "\\" && quote !== "'") { + const next = input[i + 1]; + if (quote === '"' && next !== '"' && next !== "\\") { + value += char; + started = true; + continue; + } escaped = true; started = true; } else if (quote) { diff --git a/test/tui.test.mjs b/test/tui.test.mjs index cce4552..1615e37 100644 --- a/test/tui.test.mjs +++ b/test/tui.test.mjs @@ -19,6 +19,13 @@ test("TUI command parsing supports escaped whitespace and empty arguments", () = ]); }); +test("TUI command parsing preserves Windows paths inside double quotes", () => { + assert.deepEqual(splitCommandLine('/run "C:\\Users\\mosh\\script.mosh"'), [ + "/run", + "C:\\Users\\mosh\\script.mosh", + ]); +}); + test("TUI command parsing rejects incomplete quoting", () => { assert.throws(() => splitCommandLine('/coinpay --description "unfinished'), /unterminated/); assert.throws(() => splitCommandLine("/ugig trailing\\"), /trailing escape/);