Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit c72f8b1

Browse files
veraciouxopencode
authored andcommitted
fix: tui: Fix /editor command (anomalyco#3663)
1 parent eb304f4 commit c72f8b1

5 files changed

Lines changed: 7 additions & 11 deletions

File tree

packages/opencode/src/cli/cmd/tui/component/dialog-command.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ function init() {
4141
})
4242

4343
const result = {
44-
trigger(name: string) {
44+
trigger(name: string, source?: "prompt") {
4545
for (const option of options()) {
4646
if (option.value === name) {
47-
option.onSelect?.(dialog)
47+
option.onSelect?.(dialog, source)
4848
return
4949
}
5050
}

packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export function Autocomplete(props: {
263263
{
264264
display: "/editor",
265265
description: "open editor",
266-
onSelect: () => command.trigger("prompt.editor"),
266+
onSelect: () => command.trigger("prompt.editor", "prompt"),
267267
},
268268
{
269269
display: "/help",

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,9 @@ export function Prompt(props: PromptProps) {
9898
category: "Session",
9999
keybind: "editor_open",
100100
value: "prompt.editor",
101-
onSelect: async (dialog) => {
101+
onSelect: async (dialog, trigger) => {
102102
dialog.clear()
103-
const value = input.plainText
104-
input.clear()
105-
setStore("prompt", {
106-
input: "",
107-
parts: [],
108-
})
103+
const value = trigger === "prompt" ? "" : input.plainText
109104
const content = await Editor.open({ value, renderer })
110105
if (content) {
111106
input.setText(content, { history: false })

packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface DialogSelectOption<T = any> {
3535
category?: string
3636
disabled?: boolean
3737
bg?: RGBA
38-
onSelect?: (ctx: DialogContext) => void
38+
onSelect?: (ctx: DialogContext, trigger?: "prompt") => void
3939
}
4040

4141
export type DialogSelectRef<T> = {

packages/opencode/src/cli/cmd/tui/util/editor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export namespace Editor {
2424
})
2525
await proc.exited
2626
const content = await Bun.file(filepath).text()
27+
opts.renderer.currentRenderBuffer.clear()
2728
opts.renderer.resume()
2829
opts.renderer.requestRender()
2930
return content || undefined

0 commit comments

Comments
 (0)