Skip to content

Generalize _merge_with_lcs and _pair_adjacent_changes#93

Open
pmolodo wants to merge 1 commit intopmolodowitch/diff-feature-testsfrom
pmolodowitch/ast-diff-refactor
Open

Generalize _merge_with_lcs and _pair_adjacent_changes#93
pmolodo wants to merge 1 commit intopmolodowitch/diff-feature-testsfrom
pmolodowitch/ast-diff-refactor

Conversation

@pmolodo
Copy link
Copy Markdown
Collaborator

@pmolodo pmolodo commented May 1, 2026

  • Extract the LCS-driven walk that was inlined inside diff_block_lists (and duplicated inside diff_list_nodes) into a single generic _merge_with_lcs that returns an ordered (op, element) stream.
  • Generalize _pair_adjacent_changes to take pair / wrap_deletion / wrap_insertion callbacks so it can fold the same stream for both Pandoc blocks and list items, instead of operating on already-wrapped Divs.
  • Add _pair_blocks helper carrying the per-pair recursion strategy (lists / BlockQuotes / LineBlocks) used by diff_block_lists.
  • Reduce diff_list_nodes from a hand-written merge+pair loop to a thin call into the shared helpers.

- Extract the LCS-driven walk that was inlined inside diff_block_lists
  (and duplicated inside diff_list_nodes) into a single generic
  _merge_with_lcs that returns an ordered (op, element) stream.
- Generalize _pair_adjacent_changes to take pair / wrap_deletion /
  wrap_insertion callbacks so it can fold the same stream for both
  Pandoc blocks and list items, instead of operating on already-wrapped
  Divs.
- Add _pair_blocks helper carrying the per-pair recursion strategy
  (lists / BlockQuotes / LineBlocks) used by diff_block_lists.
- Reduce diff_list_nodes from a hand-written merge+pair loop to a thin
  call into the shared helpers.
@pmolodo pmolodo requested a review from OleksiyPuzikov May 1, 2026 23:30
Copy link
Copy Markdown
Contributor

@OleksiyPuzikov OleksiyPuzikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

2 participants