diff --git a/README.md b/README.md index ff61f5d..fe7dcaa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pi-edit-last -Edit assistant replies since the last user message in your external editor (Zed, VS Code, etc.). +Edit assistant replies since the last user message in your external editor (Zed, VS Code, etc.). Then pi receives your edited version as a revision request. ## Install @@ -27,4 +27,4 @@ export VISUAL=zed # or code, vim, etc. ## Related -- [pi-studio](https://github.com/omaclaren/pi-studio) — Collection of pi extensions +- [pi-studio](https://github.com/omaclaren/pi-studio) — web editor diff --git a/index.ts b/index.ts index 10e28f1..a4eaa3b 100644 --- a/index.ts +++ b/index.ts @@ -77,7 +77,12 @@ function buildRevisionPrompt(editedText: string): string { // Open editor and wait for it to close, returning the edited content function editInExternalEditor(content: string): string | null { - const editor = process.env.VISUAL || process.env.EDITOR || "vi"; + let editor = process.env.VISUAL || process.env.EDITOR || "vi"; + + // VSCode needs --wait to block until file is closed + if (editor === "code") { + editor = "code --wait"; + } const tmpDir = mkdtempSync(join(tmpdir(), "pi-edit-")); const tmpFile = join(tmpDir, "edit.txt");