MCPcopy Index your code
hub / github.com/continuedev/continue / linesMatch

Function linesMatch

core/diff/util.ts:24–40  ·  view source on GitHub ↗
(lineA: string, lineB: string, linesBetween = 0)

Source from the content-addressed store, hash-verified

22const END_BRACKETS = ["}", "});", "})"];
23
24function linesMatch(lineA: string, lineB: string, linesBetween = 0): boolean {
25 // Require a perfect (without padding) match for these lines
26 // Otherwise they are edit distance 1 from empty lines and other single char lines (e.g. each other)
27 if (["}", "*", "});", "})"].includes(lineA.trim())) {
28 return lineA.trim() === lineB.trim();
29 }
30
31 const d = distance(lineA, lineB);
32
33 return (
34 // Should be more unlikely for lines to fuzzy match if they are further away
35 (d / Math.max(lineA.length, lineB.length) <=
36 Math.max(0, 0.48 - linesBetween * 0.06) ||
37 lineA.trim() === lineB.trim()) &&
38 lineA.trim() !== ""
39 );
40}
41
42/**
43 * Used to find a match for a new line in an array of old lines.

Callers 1

matchLineFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected