MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / computeEditsFromContents

Function computeEditsFromContents

source code/hooks/useDiffInIDE.ts:172–202  ·  view source on GitHub ↗
(
  filePath: string,
  oldContent: string,
  newContent: string,
  editMode: 'single' | 'multiple',
)

Source from the content-addressed store, hash-verified

170 * to apply any edits the user may have made to the new contents.
171 */
172export function computeEditsFromContents(
173 filePath: string,
174 oldContent: string,
175 newContent: string,
176 editMode: 'single' | 'multiple',
177): FileEdit[] {
178 // Use unformatted patches, otherwise the edits will be formatted.
179 const singleHunk = editMode === 'single'
180 const patch = getPatchFromContents({
181 filePath,
182 oldContent,
183 newContent,
184 singleHunk,
185 })
186
187 if (patch.length === 0) {
188 return []
189 }
190
191 // For single edit mode, verify we only got one hunk
192 if (singleHunk && patch.length > 1) {
193 logError(
194 new Error(
195 `Unexpected number of hunks: ${patch.length}. Expected 1 hunk.`,
196 ),
197 )
198 }
199
200 // Re-compute the edits to match the patch
201 return getEditsForPatch(patch)
202}
203
204/**
205 * Done if:

Callers 1

showDiffFunction · 0.85

Calls 3

getPatchFromContentsFunction · 0.85
getEditsForPatchFunction · 0.85
logErrorFunction · 0.50

Tested by

no test coverage detected