MCPcopy Create free account
hub / github.com/codeaashu/claude-code / applyTriggerSuggestion

Function applyTriggerSuggestion

src/hooks/useTypeahead.tsx:197–205  ·  view source on GitHub ↗
(suggestion: SuggestionItem, input: string, cursorOffset: number, triggerRe: RegExp, onInputChange: (value: string) => void, setCursorOffset: (offset: number) => void)

Source from the content-addressed store, hash-verified

195}
196const DM_MEMBER_RE = /(^|\s)@[\w-]*$/;
197function 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}
206let currentShellCompletionAbortController: AbortController | null = null;
207
208/**

Callers 1

useTypeaheadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected