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

Function isUnifiedDiffFormat

core/edit/lazy/unifiedDiffApply.ts:8–29  ·  view source on GitHub ↗
(diff: string)

Source from the content-addressed store, hash-verified

6 * 2. Contains valid diff content lines (starting with +, -, or space) which are not header lines
7 */
8export function isUnifiedDiffFormat(diff: string): boolean {
9 const lines = diff.trim().split("\n");
10
11 if (lines.length < 3) {
12 return false;
13 }
14
15 let hasHunkHeader = false;
16 let hasValidContent = false;
17
18 for (const line of lines) {
19 if (line.startsWith("---") || line.startsWith("+++")) {
20 // ignore file headers - they are not required or useful
21 } else if (line.match(/^@@ -\d+,?\d* \+\d+,?\d* @@/)) {
22 hasHunkHeader = true;
23 } else if (line.match(/^[+ -]/) || line === "") {
24 hasValidContent = true;
25 }
26 }
27
28 return hasHunkHeader && hasValidContent;
29}
30
31function extractBeforeLines(hunkLines: string[]): string[] {
32 return hunkLines

Callers 2

applyCodeBlockFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected