MCPcopy Create free account
hub / github.com/freecodexyz/free-code / formatReplacementValue

Function formatReplacementValue

src/hooks/useTypeahead.tsx:148–173  ·  view source on GitHub ↗
(options: {
  displayText: string;
  mode: string;
  hasAtPrefix: boolean;
  needsQuotes: boolean;
  isQuoted?: boolean;
  isComplete: boolean;
})

Source from the content-addressed store, hash-verified

146 * @returns The formatted replacement value
147 */
148export function formatReplacementValue(options: {
149 displayText: string;
150 mode: string;
151 hasAtPrefix: boolean;
152 needsQuotes: boolean;
153 isQuoted?: boolean;
154 isComplete: boolean;
155}): string {
156 const {
157 displayText,
158 mode,
159 hasAtPrefix,
160 needsQuotes,
161 isQuoted,
162 isComplete
163 } = options;
164 const space = isComplete ? ' ' : '';
165 if (isQuoted || needsQuotes) {
166 // Use quoted format
167 return mode === 'bash' ? `"${displayText}"${space}` : `@"${displayText}"${space}`;
168 } else if (hasAtPrefix) {
169 return mode === 'bash' ? `${displayText}${space}` : `@${displayText}${space}`;
170 } else {
171 return displayText;
172 }
173}
174
175/**
176 * Apply a shell completion suggestion by replacing the current word

Callers 1

useTypeaheadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected