more timeout race guards
This commit is contained in:
@@ -93,8 +93,11 @@ export function Prompt(props: PromptProps) {
|
|||||||
let promptPartTypeId = 0
|
let promptPartTypeId = 0
|
||||||
|
|
||||||
sdk.event.on(TuiEvent.PromptAppend.type, (evt) => {
|
sdk.event.on(TuiEvent.PromptAppend.type, (evt) => {
|
||||||
|
if (!input || input.isDestroyed) return
|
||||||
input.insertText(evt.properties.text)
|
input.insertText(evt.properties.text)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
// setTimeout is a workaround and needs to be addressed properly
|
||||||
|
if (!input || input.isDestroyed) return
|
||||||
input.getLayoutNode().markDirty()
|
input.getLayoutNode().markDirty()
|
||||||
input.gotoBufferEnd()
|
input.gotoBufferEnd()
|
||||||
renderer.requestRender()
|
renderer.requestRender()
|
||||||
@@ -924,6 +927,8 @@ export function Prompt(props: PromptProps) {
|
|||||||
|
|
||||||
// Force layout update and render for the pasted content
|
// Force layout update and render for the pasted content
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
// setTimeout is a workaround and needs to be addressed properly
|
||||||
|
if (!input || input.isDestroyed) return
|
||||||
input.getLayoutNode().markDirty()
|
input.getLayoutNode().markDirty()
|
||||||
renderer.requestRender()
|
renderer.requestRender()
|
||||||
}, 0)
|
}, 0)
|
||||||
@@ -935,6 +940,8 @@ export function Prompt(props: PromptProps) {
|
|||||||
}
|
}
|
||||||
props.ref?.(ref)
|
props.ref?.(ref)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
// setTimeout is a workaround and needs to be addressed properly
|
||||||
|
if (!input || input.isDestroyed) return
|
||||||
input.cursorColor = theme.text
|
input.cursorColor = theme.text
|
||||||
}, 0)
|
}, 0)
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -34,9 +34,8 @@ export const { use: useKeybind, provider: KeybindProvider } = createSimpleContex
|
|||||||
timeout = setTimeout(() => {
|
timeout = setTimeout(() => {
|
||||||
if (!store.leader) return
|
if (!store.leader) return
|
||||||
leader(false)
|
leader(false)
|
||||||
if (focus) {
|
if (!focus || focus.isDestroyed) return
|
||||||
focus.focus()
|
focus.focus()
|
||||||
}
|
|
||||||
}, 2000)
|
}, 2000)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -275,7 +275,8 @@ export function Session() {
|
|||||||
|
|
||||||
function toBottom() {
|
function toBottom() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (scroll) scroll.scrollTo(scroll.scrollHeight)
|
if (!scroll || scroll.isDestroyed) return
|
||||||
|
scroll.scrollTo(scroll.scrollHeight)
|
||||||
}, 50)
|
}, 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ export function DialogExportOptions(props: DialogExportOptionsProps) {
|
|||||||
onMount(() => {
|
onMount(() => {
|
||||||
dialog.setSize("medium")
|
dialog.setSize("medium")
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (!textarea || textarea.isDestroyed) return
|
||||||
textarea.focus()
|
textarea.focus()
|
||||||
}, 1)
|
}, 1)
|
||||||
textarea.gotoLineEnd()
|
textarea.gotoLineEnd()
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export function DialogPrompt(props: DialogPromptProps) {
|
|||||||
onMount(() => {
|
onMount(() => {
|
||||||
dialog.setSize("medium")
|
dialog.setSize("medium")
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (!textarea || textarea.isDestroyed) return
|
||||||
textarea.focus()
|
textarea.focus()
|
||||||
}, 1)
|
}, 1)
|
||||||
textarea.gotoLineEnd()
|
textarea.gotoLineEnd()
|
||||||
|
|||||||
Reference in New Issue
Block a user