fix(tui): reopen autocomplete after backspace deletes space (#6031)
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
This commit is contained in:
@@ -601,8 +601,31 @@ export function Autocomplete(props: {
|
|||||||
(store.visible === "/" && value.match(/^\S+\s+\S+\s*$/))
|
(store.visible === "/" && value.match(/^\S+\s+\S+\s*$/))
|
||||||
) {
|
) {
|
||||||
hide()
|
hide()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if autocomplete should reopen (e.g., after backspace deleted a space)
|
||||||
|
const offset = props.input().cursorOffset
|
||||||
|
if (offset === 0) return
|
||||||
|
|
||||||
|
// Check for "/" at position 0 - reopen slash commands
|
||||||
|
if (value.startsWith("/") && !value.slice(0, offset).match(/\s/)) {
|
||||||
|
show("/")
|
||||||
|
setStore("index", 0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for "@" trigger - find the nearest "@" before cursor with no whitespace between
|
||||||
|
const text = value.slice(0, offset)
|
||||||
|
const idx = text.lastIndexOf("@")
|
||||||
|
if (idx === -1) return
|
||||||
|
|
||||||
|
const between = text.slice(idx)
|
||||||
|
const before = idx === 0 ? undefined : value[idx - 1]
|
||||||
|
if ((before === undefined || /\s/.test(before)) && !between.match(/\s/)) {
|
||||||
|
show("@")
|
||||||
|
setStore("index", idx)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onKeyDown(e: KeyEvent) {
|
onKeyDown(e: KeyEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user