MCPcopy Index your code
hub / github.com/anomalyco/opencode / applyReplacements

Function applyReplacements

packages/opencode/src/patch/index.ts:398–415  ·  view source on GitHub ↗
(lines: string[], replacements: Array<[number, number, string[]]>)

Source from the content-addressed store, hash-verified

396}
397
398function applyReplacements(lines: string[], replacements: Array<[number, number, string[]]>): string[] {
399 // Apply replacements in reverse order to avoid index shifting
400 const result = [...lines]
401
402 for (let i = replacements.length - 1; i >= 0; i--) {
403 const [startIdx, oldLen, newSegment] = replacements[i]
404
405 // Remove old lines
406 result.splice(startIdx, oldLen)
407
408 // Insert new lines
409 for (let j = 0; j < newSegment.length; j++) {
410 result.splice(startIdx + j, 0, newSegment[j])
411 }
412 }
413
414 return result
415}
416
417// Normalize Unicode punctuation to ASCII equivalents (like Rust's normalize_unicode)
418function normalizeUnicode(str: string): string {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected