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

Function applyDirectorySuggestion

src/hooks/useTypeahead.tsx:237–252  ·  view source on GitHub ↗
(input: string, suggestionId: string, tokenStartPos: number, tokenLength: number, isDirectory: boolean)

Source from the content-addressed store, hash-verified

235 * @returns Object with the new input text and cursor position
236 */
237export function applyDirectorySuggestion(input: string, suggestionId: string, tokenStartPos: number, tokenLength: number, isDirectory: boolean): {
238 newInput: string;
239 cursorPos: number;
240} {
241 const suffix = isDirectory ? '/' : ' ';
242 const before = input.slice(0, tokenStartPos);
243 const after = input.slice(tokenStartPos + tokenLength);
244 // Always add @ prefix - if token already has it, we're replacing
245 // the whole token (including @) with @suggestion.id
246 const replacement = '@' + suggestionId + suffix;
247 const newInput = before + replacement + after;
248 return {
249 newInput,
250 cursorPos: before.length + replacement.length
251 };
252}
253
254/**
255 * Extract a completable token at the cursor position

Callers 1

useTypeaheadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected