|
|
@@ -601,8 +601,31 @@ export function Autocomplete(props: {
|
|
|
(store.visible === "/" && value.match(/^\S+\s+\S+\s*$/))
|
|
|
) {
|
|
|
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) {
|