fix: stop showing auto complete if user types a space

This commit is contained in:
Aiden Cline
2025-11-04 13:22:18 -06:00
parent ee1ff8cc07
commit 52e2b40610

View File

@@ -54,6 +54,12 @@ export function Autocomplete(props: {
const val = props.input().getTextRange(store.index + 1, props.input().cursorOffset + 1) const val = props.input().getTextRange(store.index + 1, props.input().cursorOffset + 1)
// If the filter contains a space, hide the autocomplete
if (val.includes(" ")) {
hide()
return undefined
}
return val return val
}) })
@@ -373,7 +379,17 @@ export function Autocomplete(props: {
return store.visible return store.visible
}, },
onInput() { onInput() {
if (store.visible && props.input().cursorOffset <= store.index) hide() if (store.visible) {
if (props.input().cursorOffset <= store.index) {
hide()
return
}
// Check if a space was typed after the trigger character
const currentText = props.input().getTextRange(store.index + 1, props.input().cursorOffset + 1)
if (currentText.includes(" ")) {
hide()
}
}
}, },
onKeyDown(e: KeyEvent) { onKeyDown(e: KeyEvent) {
if (store.visible) { if (store.visible) {