sdiff: implement the `|` marker for changed lines

Open
#272 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Quiet
Tech stack
rust
Domain
cli

Research direction

Start in src/side_diff.rs and trace how the current engine diff’s Left, Right, and Both results are consumed. Verify the change with the provided diff -y example, including a hunk with unequal deletion and insertion counts. Done means positional pairs in each contiguous change hunk print with |, while leftovers retain < or > and unchanged lines remain unaffected.

Written by the indexing model from the issue text.

Description

src/side_diff.rs currently emits only <, > and blank gutters. Lines that exist in both files but differ are printed as a separate deletion and insertion instead of a single row with |.

The | is produced at print time, by pairing positionally inside a contiguous change hunk. For a run of N deletions and M insertions, the first min(N, M) are printed as pairs with |, and the leftovers keep < or >. The pairing is positional, so the two lines of a | row need nothing in common:

$ diff -y --width=40 L R      # L: a,b1,b2,b3,c   R: a,X,c
a			a
b1		   |	X
b2		   <
b3		   <
c			c

So the change is confined to the consumption of the current engine diff's. Buffer the run of Left/Right results, and on the next Both (or at EOF) flush it with the pairing above.

Dominant language
Rust
Stars
276
Forks
39
Avg merge
3h 27m
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from uutils/diffutils

All issues in uutils/diffutils

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.