镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

sdiff: fix the layout of unchanged rows, blank lines and cut tabs #300

Description

@sami-daniel

src/side_diff.rs pads the left half up to a fixed column and writes the right half after it, instead of padding from the column where the text ended. Three rows come out different from GNU diff:

  • The right half of an unchanged row starts at half_width + 3 instead of column two. The two are the same at the default --width=130, so it only shows at other widths and with --expand-tabs.
  • A blank line common to both files is padded up to column two instead of left empty.
  • A tab that reaches the end of the half is dropped, and the text after it is still printed. GNU diff cuts the row at that tab.

Tabs are shown as ^I and line ends as $:

$ diff -y --width=40 L R | cat -A      # L: a,(blank),b,c   R: a,(blank),c
a^I^I   a$
^I^I   $
b^I^I   <$
c^I^I   c$

$ diff -y --width=10 L R | cat -A      # L: a<TAB>b,c   R: c
ab  <$
c    c$

GNU diff 3.10 prints:

a^I^I^Ia$
$
b^I^I   <$
c^I^I^Ic$

a   <$
c^Ic$

So the change is confined to process_half_line and push_output. Print only the text of each half, keep the column where the output stopped, and pad from that column to the marker and to column two.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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