fix(coding-agent): preserve POSIX editor quoting

This commit is contained in:
metaphorics
2026-08-05 11:42:28 +00:00
parent 1e492d6ff9
commit e9ee424ded
2 changed files with 26 additions and 3 deletions
@@ -1,5 +1,8 @@
import { afterEach, describe, expect, it } from "bun:test";
import { getEditorCommand } from "../src/utils/external-editor";
import * as fs from "node:fs";
import * as path from "node:path";
import { TempDir } from "@oh-my-pi/pi-utils";
import { getEditorCommand, openInEditor } from "../src/utils/external-editor";
interface MutableProcess {
platform: NodeJS.Platform;
@@ -61,3 +64,21 @@ describe("getEditorCommand", () => {
expect(getEditorCommand()).toBeUndefined();
});
});
describe("openInEditor", () => {
it.skipIf(process.platform === "win32")("supports quoted editor paths containing spaces", async () => {
const tempDir = TempDir.createSync("@external-editor-");
try {
const editorPath = path.join(tempDir.path(), "My Editor", "edit");
fs.mkdirSync(path.dirname(editorPath), { recursive: true });
await Bun.write(editorPath, '#!/bin/sh\nprintf "edited" > "$1"\n');
fs.chmodSync(editorPath, 0o755);
const result = await openInEditor(`"${editorPath}"`, "original");
expect(result).toBe("edited");
} finally {
await tempDir.remove();
}
});
});