GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — diff: place -y gutter marker at the middle of the gutter by nagendramohan · Pull Request #277 · uutils/diffutils

Conversation

@nagendramohan

@nagendramohan nagendramohan commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

In side-by-side (-y) output the gutter marker was written wherever process_half_line stopped
padding the left half (one column past sdiff_half_width), not at separator_pos (the middle of
the gutter). Those agree only when the gutter is 3–4 columns wide, so the default
--width=130 --tabsize=8 (gutter 3) looked right while other widths/tab sizes drifted — e.g.
--width=40 placed < at column 17 instead of 19.

Pad from half_width + 1 up to separator_pos before writing the marker so it lands at the gutter
middle, matching GNU sdiff. format_tabs_and_spaces is a no-op when already at/past separator_pos,
so narrow gutters are unaffected. Added a regression test at --width=40.

Fixes #269.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nagendramohan
diff: place -y gutter marker at the middle of the gutter
7d3f389
In side-by-side output the gutter marker was written wherever
process_half_line stopped padding the left half (one column past
sdiff_half_width), not at separator_pos (the middle of the gutter).
Those agree only when the gutter is 3 or 4 columns wide, so the default
--width=130 --tabsize=8 (gutter 3) looked right while other widths/tab
sizes drifted (e.g. --width=40 placed '<' at column 17 instead of 19).

Pad from half_width + 1 up to separator_pos before writing the marker so
it lands at the gutter middle, matching GNU sdiff. format_tabs_and_spaces
is a no-op when already at/past separator_pos, so narrow gutters are
unaffected. Add a regression test at --width=40.

Fixes uutils#269
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

GNU diffutils testsuite comparison:

Test results comparison:
  Current:   TOTAL: 33 / PASSED: 0 / FAILED: 33 / SKIPPED: 0
  Reference: TOTAL: 33 / PASSED: 8 / FAILED: 21 / SKIPPED: 4

Changes from main branch:
  TOTAL: +0
  PASSED: -8
  FAILED: +12

New test failures (12):
  - basic
  - bignum
  - brief-vs-stat-zero-kernel-lies
  - bug-64316
  - cmp
  - diff3
  - help-version
  - large-subopt
  - strcoll-0-names
  - strip-trailing-cr
  - timezone
  - y2038-vs-32bit
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sylvestre
sylvestre reviewed Sep 29, 2026
View reviewed changes
Comment thread src/side_diff.rs Outdated
// `process_half_line` left the cursor one column past the half width. The gutter marker
// belongs at the middle of the gutter (`separator_pos`), which is only `half_width + 1`
// when the gutter is 3 or 4 columns wide; pad up to it for wider gutters so the marker
// doesn't drift (see #269). `format_tabs_and_spaces` is a no-op when already at/past it.

@sylvestre sylvestre Sep 29, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

4 lines of comment for a one-liner, could you please make it shorter? :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sylvestre
sylvestre reviewed Sep 29, 2026
View reviewed changes
Comment thread src/side_diff.rs Outdated
// Regression test for #269: the `-y` gutter marker must sit at the middle of the gutter
// (separator_pos) regardless of gutter width. At the default width (gutter 3) the marker
// was already correct; at other widths it drifted. Here width=40 yields a wider gutter, so
// the marker must land at column 19 (matching GNU), not the old `half_width + 1`.

@sylvestre sylvestre Sep 29, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

same here, please make it shorter

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sylvestre
sylvestre reviewed Sep 29, 2026
View reviewed changes
Comment thread src/side_diff.rs
// (separator_pos) regardless of gutter width. At the default width (gutter 3) the marker
// was already correct; at other widths it drifted. Here width=40 yields a wider gutter, so
// the marker must land at column 19 (matching GNU), not the old `half_width + 1`.
#[test]

@sylvestre sylvestre Sep 29, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

please also add a test in tests/integration.rs with -y --width=40

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nagendramohan nagendramohan Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks! Shortened both comments and added an integration test covering -y --width=40 in both --expand-tabs and the default (tab-path) modes, asserting the marker sits at the gutter middle.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sylvestre
sylvestre reviewed Sep 29, 2026
View reviewed changes
Comment thread src/side_diff.rs
let params = Params {
tabsize: 8,
expand_tabs: true,
width: 40,

@sylvestre sylvestre Sep 29, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

could you please also test with expand_tabs: false?
that is the default, and the padding goes through the tab path

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nagendramohan
diff: address review — shorten comments and add -y width tests
ab9f8d9
Shorten the two long comments per review, and add an integration test in
tests/integration.rs exercising `-y --width=40` in both the default
(expand_tabs: false, tab-padding path) and --expand-tabs modes, asserting
the gutter marker lands at the middle of the gutter.
@nagendramohan
nagendramohan requested a review from sylvestre September 29, 2026 05:51
sylvestre
sylvestre reviewed Sep 30, 2026
View reviewed changes
Comment thread tests/integration.rs Outdated
}

// Visual (tab-aware) column of the `-y` gutter marker on the first output line.
fn side_marker_visual_column(output: &[u8], tabsize: usize) -> Option<usize> {

@sylvestre sylvestre Sep 30, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

could we just compare the whole stdout instead of this helper?
simpler, and it would also check the exact tabs/spaces emitted

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nagendramohan
diff: compare full -y stdout in the gutter marker test
add112b
Per review, assert the exact stdout for both --expand-tabs and the
default tab path instead of a column helper, so the test also pins the
exact tabs/spaces emitted.
@sylvestre
sylvestre merged commit 7aa5409 into uutils:main Oct 5, 2026
31 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@sylvestre

sylvestre commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Thanks for your PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BrewTestBot BrewTestBot mentioned this pull request Oct 23, 2026
uutils-diffutils 0.6.0 Homebrew/homebrew-core#320660
Merged
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sylvestre sylvestre sylvestre left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

diff: -y draws the gutter marker at the wrong column unless the gutter is 3 or 4 columns wide

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@nagendramohan @sylvestre
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.