mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
tui: fix keybind timeout management and add null safety
This commit is contained in:
parent
10d9b0c143
commit
36dfbc55bd
1 changed files with 4 additions and 2 deletions
|
|
@ -24,12 +24,13 @@ export function init() {
|
|||
const renderer = useRenderer()
|
||||
|
||||
let focus: Renderable | null
|
||||
let timeout: NodeJS.Timeout
|
||||
function leader(active: boolean) {
|
||||
if (active) {
|
||||
setStore("leader", true)
|
||||
focus = renderer.currentFocusedRenderable
|
||||
focus?.blur()
|
||||
setTimeout(() => {
|
||||
timeout = setTimeout(() => {
|
||||
leader(false)
|
||||
}, 2000)
|
||||
return
|
||||
|
|
@ -40,6 +41,7 @@ export function init() {
|
|||
focus.focus()
|
||||
}
|
||||
setStore("leader", false)
|
||||
clearTimeout(timeout)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +51,7 @@ export function init() {
|
|||
return
|
||||
}
|
||||
|
||||
if (store.leader) {
|
||||
if (store.leader && evt.name) {
|
||||
setImmediate(() => {
|
||||
leader(false)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue