Skip to content

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

Description

@sami-daniel

In side-by-side output, Config::separator_pos holds the middle of the gutter, but the gutter marker is not written there. It goes wherever process_half_line stopped padding the left half line, which is one column past sdiff_half_width. separator_pos is only read afterwards, to pad from the marker to the start of column two.

For a gutter g columns wide, separator_pos is sdiff_half_width + (g - 1) / 2. The two positions agree only when g is 3 or 4. The default --width=130 --tabsize=8 produces a gutter of exactly 3, which is why the default output looks correct, but any width or tab size where the tab alignment pushes column two further past the balance point drifts. --width=130 --tabsize=4 is off by one, --width=200 --tabsize=8 by two, --width=130 --tabsize=128 by 61.

printf 'aa\n' > f1; : > f2
diff -y --width=40 f1 f2 | expand | cat -A
aa                 <$
diffutils diff -y --width=40 f1 f2 | expand | cat -A
aa               <$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions