`ScreenDiff` across different sizes prints rows unclipped, so the columns and the `^` markers misalign

Open Beginner friendly
#649 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
testing-qa

Research direction

Read screen/diff.rs around lines 87–92 and 296–307, then inspect the existing tests in diff.rs. The issue identifies row_text, rect_text(..cols, row..=row), and the CLI colored rendering at termlens-cli/src/main.rs:499 as relevant entry points. Done means diffs across different screen sizes keep the column separators aligned in plain and colored output, with a regression test in diff.rs.

Written by the indexing model from the issue text.

Description

bug good first issue

What happens.

termlens inspect --size 30x3 sh -c 'printf "hello world and more text"' > big.snap
termlens inspect --size 10x3 sh -c 'printf jello' > small.snap
termlens diff big.snap small.snap
compared over the 10x3 overlap; the rest is clipped
  0 │hello world and more text│jello
    │^     ^^^^│^     ^^^^

The header says the rest is clipped, but the before row is printed whole. So the │ separators do not line up with the marker line's, and the after-side carets sit under the wrong cells. Reproduced through the library too: a 12x2 screen diffed against a 6x2 one gives │hello world!│hellO over │ ^ │ ^. The rows field's doc ("The rows of the taller screen") does not say this either.

Cause. screen/diff.rs:87-92 stores each screen's full row_text. pad (:296-307) pads to the overlap width but never truncates.

Related, from the CLI's coloured mode. The before side is laid out on before.cols. Changed trailing blanks on the after side are wrapped in SGR, so the trim_end at termlens-cli/src/main.rs:499 leaves \e[32m \e[0m runs.

Fix. Store each row clipped to the overlap columns (rect_text(..cols, row..=row)), and render the coloured form from the same clipped text.

Done when a diff across sizes keeps every │ in one column, plain and coloured, with a test in diff.rs.

Dominant language
Rust
Stars
28
Forks
24
Avg merge
11h 23m
Merged PRs (30d)
42

Getting set up

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 vyncint/termlens

All issues in vyncint/termlens

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.