MCPcopy Create free account
hub / github.com/arctic-cli/interface / seekSequence

Function seekSequence

packages/arctic/src/patch/index.ts:410–430  ·  view source on GitHub ↗
(lines: string[], pattern: string[], startIndex: number)

Source from the content-addressed store, hash-verified

408 }
409
410 function seekSequence(lines: string[], pattern: string[], startIndex: number): number {
411 if (pattern.length === 0) return -1
412
413 // Simple substring search implementation
414 for (let i = startIndex; i <= lines.length - pattern.length; i++) {
415 let matches = true
416
417 for (let j = 0; j < pattern.length; j++) {
418 if (lines[i + j] !== pattern[j]) {
419 matches = false
420 break
421 }
422 }
423
424 if (matches) {
425 return i
426 }
427 }
428
429 return -1
430 }
431
432 function generateUnifiedDiff(oldContent: string, newContent: string): string {
433 const oldLines = oldContent.split("\n")

Callers 1

computeReplacementsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected