Skip to content

feat(engine): add linediff engine and universal line diff fallback - #45

Merged
HarshK97 merged 2 commits into
mainfrom
feature/line-diff
Aug 3, 2026
Merged

feat(engine): add linediff engine and universal line diff fallback#45
HarshK97 merged 2 commits into
mainfrom
feature/line-diff

Conversation

@HarshK97

@HarshK97 HarshK97 commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Problem

  1. Structural AST diffing can generate spurious matches across unrelated blocks when untouched lines pair up with edited nodes. So we need a fast line-level diffing engine to implement Matsumoto et al.'s two-group line partitioning strategy ("Beyond GumTree").
  2. When tree-sitter cannot detect a file's language or fails to parse its AST, diffm previously failed with a hard parse error. So unsupported file formats and plaintext files couldn't be diffed.

What Changed

  • Line Diff Engine: Added LineDiff(linesA, linesB) in internal/engine/linediff.go using a 1D DP flat slice and prefix/suffix line trimming.
  • Universal Line Diff Fallback: Added BuildLineDiffEnvelope in internal/serialize/json.go and updated computeDiff in cmd/pipeline.go. When AST parsing fails or file extensions are unsupported, CLI and TUI fall back to line-level diffing instead of erroring out.
  • TUI Deduplication: Replaced the local generateLineDiff helper in internal/tui/model.go to use serialize.BuildLineDiffEnvelope.
  • Tests: Expanded unit tests in internal/engine/linediff_test.go for line trimming edge cases and added TestDiffFallbackLineDiff in cmd/diff_test.go.

@HarshK97 HarshK97 changed the title feat(engine): add linediff with prefix and suffix trimming feat(engine): add linediff engine and universal line diff fallback Aug 3, 2026
@HarshK97
HarshK97 merged commit 1d37d9a into main Aug 3, 2026
8 checks passed
@HarshK97
HarshK97 deleted the feature/line-diff branch August 3, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant