MCPcopy Index your code
hub / github.com/codeaashu/claude-code / replaceSpansKeepQuotes

Function replaceSpansKeepQuotes

src/utils/bash/treeSitterAnalysis.ts:194–207  ·  view source on GitHub ↗

* Replaces spans with just the quote delimiters (preserving ' and " characters).

(
  command: string,
  spans: Array<[number, number, string, string]>,
)

Source from the content-addressed store, hash-verified

192 * Replaces spans with just the quote delimiters (preserving ' and " characters).
193 */
194function replaceSpansKeepQuotes(
195 command: string,
196 spans: Array<[number, number, string, string]>,
197): string {
198 if (spans.length === 0) return command
199
200 const sorted = dropContainedSpans(spans).sort((a, b) => b[0] - a[0])
201 let result = command
202 for (const [start, end, open, close] of sorted) {
203 // Replace content but keep the quote delimiters
204 result = result.slice(0, start) + open + close + result.slice(end)
205 }
206 return result
207}
208
209/**
210 * Extract quote context from the tree-sitter AST.

Callers 1

extractQuoteContextFunction · 0.85

Calls 1

dropContainedSpansFunction · 0.85

Tested by

no test coverage detected