fix: tui: Fix /editor command (#3663)

This commit is contained in:
Haris Gušić
2025-11-01 01:12:28 +01:00
committed by opencode
parent eb304f4115
commit c72f8b17c6
5 changed files with 7 additions and 11 deletions

View File

@@ -41,10 +41,10 @@ function init() {
}) })
const result = { const result = {
trigger(name: string) { trigger(name: string, source?: "prompt") {
for (const option of options()) { for (const option of options()) {
if (option.value === name) { if (option.value === name) {
option.onSelect?.(dialog) option.onSelect?.(dialog, source)
return return
} }
} }

View File

@@ -263,7 +263,7 @@ export function Autocomplete(props: {
{ {
display: "/editor", display: "/editor",
description: "open editor", description: "open editor",
onSelect: () => command.trigger("prompt.editor"), onSelect: () => command.trigger("prompt.editor", "prompt"),
}, },
{ {
display: "/help", display: "/help",

View File

@@ -98,14 +98,9 @@ export function Prompt(props: PromptProps) {
category: "Session", category: "Session",
keybind: "editor_open", keybind: "editor_open",
value: "prompt.editor", value: "prompt.editor",
onSelect: async (dialog) => { onSelect: async (dialog, trigger) => {
dialog.clear() dialog.clear()
const value = input.plainText const value = trigger === "prompt" ? "" : input.plainText
input.clear()
setStore("prompt", {
input: "",
parts: [],
})
const content = await Editor.open({ value, renderer }) const content = await Editor.open({ value, renderer })
if (content) { if (content) {
input.setText(content, { history: false }) input.setText(content, { history: false })

View File

@@ -35,7 +35,7 @@ export interface DialogSelectOption<T = any> {
category?: string category?: string
disabled?: boolean disabled?: boolean
bg?: RGBA bg?: RGBA
onSelect?: (ctx: DialogContext) => void onSelect?: (ctx: DialogContext, trigger?: "prompt") => void
} }
export type DialogSelectRef<T> = { export type DialogSelectRef<T> = {

View File

@@ -24,6 +24,7 @@ export namespace Editor {
}) })
await proc.exited await proc.exited
const content = await Bun.file(filepath).text() const content = await Bun.file(filepath).text()
opts.renderer.currentRenderBuffer.clear()
opts.renderer.resume() opts.renderer.resume()
opts.renderer.requestRender() opts.renderer.requestRender()
return content || undefined return content || undefined