mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-26 16:19:40 +00:00
fix(tui): open external editor in worktree cwd (#29130)
This commit is contained in:
parent
5ca613e28e
commit
d5f397a2da
3 changed files with 17 additions and 4 deletions
|
|
@ -509,7 +509,11 @@ export function Prompt(props: PromptProps) {
|
|||
const nonTextParts = store.prompt.parts.filter((p) => p.type !== "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
|
||||
|
||||
input.setText(content)
|
||||
|
|
|
|||
|
|
@ -965,7 +965,11 @@ export function Session() {
|
|||
|
||||
if (options.openWithoutSaving) {
|
||||
// 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 {
|
||||
const exportDir = process.cwd()
|
||||
const filename = options.filename.trim()
|
||||
|
|
@ -974,7 +978,11 @@ export function Session() {
|
|||
await Filesystem.write(filepath, transcript)
|
||||
|
||||
// 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) {
|
||||
await Filesystem.write(filepath, result)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { CliRenderer } from "@opentui/core"
|
|||
import { Filesystem } from "@/util/filesystem"
|
||||
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"]
|
||||
if (!editor) return
|
||||
|
||||
|
|
@ -19,6 +19,7 @@ export async function open(opts: { value: string; renderer: CliRenderer }): Prom
|
|||
try {
|
||||
const parts = editor.split(" ")
|
||||
const proc = Process.spawn([...parts, filepath], {
|
||||
cwd: opts.cwd,
|
||||
stdin: "inherit",
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue