fix(windows): restore /editor support on Windows (#17146)

This commit is contained in:
AbigailJixiangyuyu
2026-03-17 06:11:02 +08:00
committed by GitHub
parent 68809365df
commit e9a17e4480
2 changed files with 19 additions and 12 deletions

View File

@@ -17,17 +17,21 @@ export namespace Editor {
await Filesystem.write(filepath, opts.value) await Filesystem.write(filepath, opts.value)
opts.renderer.suspend() opts.renderer.suspend()
opts.renderer.currentRenderBuffer.clear() opts.renderer.currentRenderBuffer.clear()
const parts = editor.split(" ") try {
const proc = Process.spawn([...parts, filepath], { const parts = editor.split(" ")
stdin: "inherit", const proc = Process.spawn([...parts, filepath], {
stdout: "inherit", stdin: "inherit",
stderr: "inherit", stdout: "inherit",
}) stderr: "inherit",
await proc.exited shell: process.platform === "win32",
const content = await Filesystem.readText(filepath) })
opts.renderer.currentRenderBuffer.clear() await proc.exited
opts.renderer.resume() const content = await Filesystem.readText(filepath)
opts.renderer.requestRender() return content || undefined
return content || undefined } finally {
opts.renderer.currentRenderBuffer.clear()
opts.renderer.resume()
opts.renderer.requestRender()
}
} }
} }

View File

@@ -3,6 +3,7 @@ import { buffer } from "node:stream/consumers"
export namespace Process { export namespace Process {
export type Stdio = "inherit" | "pipe" | "ignore" export type Stdio = "inherit" | "pipe" | "ignore"
export type Shell = boolean | string
export interface Options { export interface Options {
cwd?: string cwd?: string
@@ -10,6 +11,7 @@ export namespace Process {
stdin?: Stdio stdin?: Stdio
stdout?: Stdio stdout?: Stdio
stderr?: Stdio stderr?: Stdio
shell?: Shell
abort?: AbortSignal abort?: AbortSignal
kill?: NodeJS.Signals | number kill?: NodeJS.Signals | number
timeout?: number timeout?: number
@@ -60,6 +62,7 @@ export namespace Process {
cwd: opts.cwd, cwd: opts.cwd,
env: opts.env === null ? {} : opts.env ? { ...process.env, ...opts.env } : undefined, env: opts.env === null ? {} : opts.env ? { ...process.env, ...opts.env } : undefined,
stdio: [opts.stdin ?? "ignore", opts.stdout ?? "ignore", opts.stderr ?? "ignore"], stdio: [opts.stdin ?? "ignore", opts.stdout ?? "ignore", opts.stderr ?? "ignore"],
shell: opts.shell,
windowsHide: process.platform === "win32", windowsHide: process.platform === "win32",
}) })