mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-21 17:54:23 +01:00
fix: tui: Fix /editor command (#3663)
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -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 })
|
||||||
|
|||||||
@@ -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> = {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user