Fix file picker not reopening after Escape

- Clear ignored @ position when user moves away from it
- Track when @ position changes and remove old position from ignored set
- Allows file picker to work again on new @ mentions
- Example: @app (Escape) → @file (picker opens for new @)
This commit is contained in:
Shantur Rathore
2025-10-24 00:36:32 +01:00
parent fb9d3a08eb
commit debaef628a

View File

@@ -131,14 +131,26 @@ export default function PromptInput(props: PromptInputProps) {
const textBeforeCursor = value.substring(0, cursorPos)
const lastAtIndex = textBeforeCursor.lastIndexOf("@")
if (lastAtIndex !== -1 && !ignoredAtPositions().has(lastAtIndex)) {
const previousAtPosition = atPosition()
if (previousAtPosition !== null && lastAtIndex !== previousAtPosition) {
setIgnoredAtPositions((prev) => {
const next = new Set(prev)
next.delete(previousAtPosition)
return next
})
}
if (lastAtIndex !== -1) {
const textAfterAt = value.substring(lastAtIndex + 1, cursorPos)
const hasSpace = textAfterAt.includes(" ") || textAfterAt.includes("\n")
if (!hasSpace && cursorPos === lastAtIndex + textAfterAt.length + 1) {
setAtPosition(lastAtIndex)
setFileSearchQuery(textAfterAt)
setShowFilePicker(true)
if (!ignoredAtPositions().has(lastAtIndex)) {
setAtPosition(lastAtIndex)
setFileSearchQuery(textAfterAt)
setShowFilePicker(true)
}
return
}
}