MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / findContextCore

Function findContextCore

sdk/src/tools/apply-patch.ts:299–327  ·  view source on GitHub ↗
(
  lines: string[],
  context: string[],
  start: number,
)

Source from the content-addressed store, hash-verified

297}
298
299function findContextCore(
300 lines: string[],
301 context: string[],
302 start: number,
303): { newIndex: number; fuzz: number } {
304 if (context.length === 0) {
305 return { newIndex: start, fuzz: 0 }
306 }
307
308 for (let i = start; i < lines.length; i += 1) {
309 if (equalsSlice(lines, context, i, (value) => value)) {
310 return { newIndex: i, fuzz: 0 }
311 }
312 }
313
314 for (let i = start; i < lines.length; i += 1) {
315 if (equalsSlice(lines, context, i, (value) => value.trimEnd())) {
316 return { newIndex: i, fuzz: 1 }
317 }
318 }
319
320 for (let i = start; i < lines.length; i += 1) {
321 if (equalsSlice(lines, context, i, (value) => value.trim())) {
322 return { newIndex: i, fuzz: 100 }
323 }
324 }
325
326 return { newIndex: -1, fuzz: 0 }
327}
328
329function findContext(
330 lines: string[],

Callers 1

findContextFunction · 0.85

Calls 1

equalsSliceFunction · 0.85

Tested by

no test coverage detected