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

Function dropContainedSpans

src/utils/bash/treeSitterAnalysis.ts:159–172  ·  view source on GitHub ↗

* Drops spans that are fully contained within another span, keeping only the * outermost. Nested quotes (e.g., `"$(echo 'hi')"`) yield overlapping spans * — the inner raw_string is found by recursing into the outer string node. * Processing overlapping spans corrupts indices since removing/replac

(
  spans: T[],
)

Source from the content-addressed store, hash-verified

157 * outer span shifts the inner span's start/end into stale positions.
158 */
159function dropContainedSpans<T extends readonly [number, number, ...unknown[]]>(
160 spans: T[],
161): T[] {
162 return spans.filter(
163 (s, i) =>
164 !spans.some(
165 (other, j) =>
166 j !== i &&
167 other[0] <= s[0] &&
168 other[1] >= s[1] &&
169 (other[0] < s[0] || other[1] > s[1]),
170 ),
171 )
172}
173
174/**
175 * Removes spans from a string, returning the string with those character

Callers 2

removeSpansFunction · 0.85
replaceSpansKeepQuotesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected