MCPcopy Create free account
hub / github.com/anomalyco/opencode / seek

Function seek

packages/core/src/patch.ts:160–172  ·  view source on GitHub ↗
(lines: ReadonlyArray<string>, pattern: ReadonlyArray<string>, start: number, eof = false)

Source from the content-addressed store, hash-verified

158}
159
160function seek(lines: ReadonlyArray<string>, pattern: ReadonlyArray<string>, start: number, eof = false) {
161 if (pattern.length === 0) return -1
162 for (const compare of [exact, rstrip, trim, normalized]) {
163 if (eof) {
164 const offset = lines.length - pattern.length
165 if (offset >= start && matches(lines, pattern, offset, compare)) return offset
166 }
167 for (let offset = start; offset <= lines.length - pattern.length; offset++) {
168 if (matches(lines, pattern, offset, compare)) return offset
169 }
170 }
171 return -1
172}
173
174function matches(
175 lines: ReadonlyArray<string>,

Callers 1

computeReplacementsFunction · 0.70

Calls 1

matchesFunction · 0.70

Tested by

no test coverage detected