| 195 | } |
| 196 | const DM_MEMBER_RE = /(^|\s)@[\w-]*$/; |
| 197 | function applyTriggerSuggestion(suggestion: SuggestionItem, input: string, cursorOffset: number, triggerRe: RegExp, onInputChange: (value: string) => void, setCursorOffset: (offset: number) => void): void { |
| 198 | const m = input.slice(0, cursorOffset).match(triggerRe); |
| 199 | if (!m || m.index === undefined) return; |
| 200 | const prefixStart = m.index + (m[1]?.length ?? 0); |
| 201 | const before = input.slice(0, prefixStart); |
| 202 | const newInput = before + suggestion.displayText + ' ' + input.slice(cursorOffset); |
| 203 | onInputChange(newInput); |
| 204 | setCursorOffset(before.length + suggestion.displayText.length + 1); |
| 205 | } |
| 206 | let currentShellCompletionAbortController: AbortController | null = null; |
| 207 | |
| 208 | /** |