You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The diff merge algorithm (findBestInsertForDelete / buildInitialPairs / emitLines / mergeModifiedLines et al.) is copy-pasted across three files with slight, mostly-accidental divergences:
Fix insertSkipBlocks in api/diff.ts — its fallback context ?? hunk.content shows a raw diff header to users (e.g. @@ -48,10 +48,16 @@). Should match the other two: "N lines hidden".
Update all three files to import from the shared module instead of defining their own copies.
Keep per-file:parseHunk (each has its own hunk-parsing wrapper), mergeAdjacentLines (only parse.ts uses it), insertSkipBlocks (different fallback logic that will be unified), worker infrastructure, and high-level parsing entry points.
The diff merge algorithm (
findBestInsertForDelete/buildInitialPairs/emitLines/mergeModifiedLineset al.) is copy-pasted across three files with slight, mostly-accidental divergences:src/browser/lib/diff-worker.tssrc/browser/ui/diff/utils/parse.tssrc/api/diff.tsPlan:
Create
src/shared/diff-merge.ts— extract the shared types (UNPAIRED,ReplaceKey,Line,ParseOptions,defaultOptions,Hunk,SkipBlock) and shared functions (calculateChangeRatio,changeToLine,buildChangeIndices,findBestInsertForDelete,buildInitialPairs,buildUnpairedDeletePrefix,hasUnpairedDeleteBetween,emitNormal,emitModified,emitLines,mergeModifiedLines,isSimilarEnough).Unify to one correct
findBestInsertForDelete— use array-index bounds (already fixed forward-only in Fix diff merge algorithm pairing deletes with wrong inserts across sections #247). Theparse.tsvariant usinglineNumberbounds is a bug, not intentional.Fix
insertSkipBlocksinapi/diff.ts— its fallbackcontext ?? hunk.contentshows a raw diff header to users (e.g.@@ -48,10 +48,16 @@). Should match the other two:"N lines hidden".Update all three files to import from the shared module instead of defining their own copies.
Keep per-file:
parseHunk(each has its own hunk-parsing wrapper),mergeAdjacentLines(onlyparse.tsuses it),insertSkipBlocks(different fallback logic that will be unified), worker infrastructure, and high-level parsing entry points.