MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / removeSpans

Function removeSpans

source code/utils/bash/treeSitterAnalysis.ts:180–191  ·  view source on GitHub ↗

* Removes spans from a string, returning the string with those character * ranges removed.

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

Source from the content-addressed store, hash-verified

178 * ranges removed.
179 */
180function removeSpans(command: string, spans: Array<[number, number]>): string {
181 if (spans.length === 0) return command
182
183 // Drop inner spans that are fully contained in an outer one, then sort by
184 // start index descending so we can splice without offset shifts.
185 const sorted = dropContainedSpans(spans).sort((a, b) => b[0] - a[0])
186 let result = command
187 for (const [start, end] of sorted) {
188 result = result.slice(0, start) + result.slice(end)
189 }
190 return result
191}
192
193/**
194 * Replaces spans with just the quote delimiters (preserving ' and " characters).

Callers 1

extractQuoteContextFunction · 0.85

Calls 1

dropContainedSpansFunction · 0.85

Tested by

no test coverage detected