fix(tui): open external editor in worktree cwd (#29130)
This commit is contained in:
@@ -509,7 +509,11 @@ export function Prompt(props: PromptProps) {
|
|||||||
const nonTextParts = store.prompt.parts.filter((p) => p.type !== "text")
|
const nonTextParts = store.prompt.parts.filter((p) => p.type !== "text")
|
||||||
|
|
||||||
const value = text
|
const value = text
|
||||||
const content = await Editor.open({ value, renderer })
|
const content = await Editor.open({
|
||||||
|
value,
|
||||||
|
renderer,
|
||||||
|
cwd: project.instance.path().worktree || project.instance.directory() || process.cwd(),
|
||||||
|
})
|
||||||
if (!content) return
|
if (!content) return
|
||||||
|
|
||||||
input.setText(content)
|
input.setText(content)
|
||||||
|
|||||||
@@ -965,7 +965,11 @@ export function Session() {
|
|||||||
|
|
||||||
if (options.openWithoutSaving) {
|
if (options.openWithoutSaving) {
|
||||||
// Just open in editor without saving
|
// Just open in editor without saving
|
||||||
await Editor.open({ value: transcript, renderer })
|
await Editor.open({
|
||||||
|
value: transcript,
|
||||||
|
renderer,
|
||||||
|
cwd: project.instance.path().worktree || project.instance.directory() || process.cwd(),
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
const exportDir = process.cwd()
|
const exportDir = process.cwd()
|
||||||
const filename = options.filename.trim()
|
const filename = options.filename.trim()
|
||||||
@@ -974,7 +978,11 @@ export function Session() {
|
|||||||
await Filesystem.write(filepath, transcript)
|
await Filesystem.write(filepath, transcript)
|
||||||
|
|
||||||
// Open with EDITOR if available
|
// Open with EDITOR if available
|
||||||
const result = await Editor.open({ value: transcript, renderer })
|
const result = await Editor.open({
|
||||||
|
value: transcript,
|
||||||
|
renderer,
|
||||||
|
cwd: project.instance.path().worktree || project.instance.directory() || process.cwd(),
|
||||||
|
})
|
||||||
if (result !== undefined) {
|
if (result !== undefined) {
|
||||||
await Filesystem.write(filepath, result)
|
await Filesystem.write(filepath, result)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { CliRenderer } from "@opentui/core"
|
|||||||
import { Filesystem } from "@/util/filesystem"
|
import { Filesystem } from "@/util/filesystem"
|
||||||
import { Process } from "@/util/process"
|
import { Process } from "@/util/process"
|
||||||
|
|
||||||
export async function open(opts: { value: string; renderer: CliRenderer }): Promise<string | undefined> {
|
export async function open(opts: { value: string; renderer: CliRenderer; cwd?: string }): Promise<string | undefined> {
|
||||||
const editor = process.env["VISUAL"] || process.env["EDITOR"]
|
const editor = process.env["VISUAL"] || process.env["EDITOR"]
|
||||||
if (!editor) return
|
if (!editor) return
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ export async function open(opts: { value: string; renderer: CliRenderer }): Prom
|
|||||||
try {
|
try {
|
||||||
const parts = editor.split(" ")
|
const parts = editor.split(" ")
|
||||||
const proc = Process.spawn([...parts, filepath], {
|
const proc = Process.spawn([...parts, filepath], {
|
||||||
|
cwd: opts.cwd,
|
||||||
stdin: "inherit",
|
stdin: "inherit",
|
||||||
stdout: "inherit",
|
stdout: "inherit",
|
||||||
stderr: "inherit",
|
stderr: "inherit",
|
||||||
|
|||||||
Reference in New Issue
Block a user