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

Function createUnifiedDiff

core/nextEdit/context/diffFormatting.ts:48–81  ·  view source on GitHub ↗
(
  beforeContent: string,
  afterContent: string,
  filePath: string,
  contextLines: number,
  workspaceDir?: string,
)

Source from the content-addressed store, hash-verified

46};
47
48const createUnifiedDiff = (
49 beforeContent: string,
50 afterContent: string,
51 filePath: string,
52 contextLines: number,
53 workspaceDir?: string,
54) => {
55 const normalizedBefore = beforeContent.endsWith("\n")
56 ? beforeContent
57 : beforeContent + "\n";
58 const normalizedAfter = afterContent.endsWith("\n")
59 ? afterContent
60 : afterContent + "\n";
61
62 // Use relative path if workspace directory is provided
63 let displayPath = filePath;
64 if (workspaceDir && filePath.startsWith(workspaceDir)) {
65 displayPath = filePath.slice(workspaceDir.length).replace(/^[\/]/, "");
66 } else if (workspaceDir) {
67 // Fallback to just the basename if we can't determine relative path
68 displayPath = getUriPathBasename(filePath);
69 }
70
71 const patch = createPatch(
72 displayPath,
73 normalizedBefore,
74 normalizedAfter,
75 undefined,
76 undefined,
77 { context: contextLines },
78 );
79
80 return patch;
81};
82
83export const createBeforeAfterDiff = (
84 beforeContent: string,

Callers 1

createDiffFunction · 0.85

Calls 2

getUriPathBasenameFunction · 0.90
replaceMethod · 0.45

Tested by

no test coverage detected