Skip to content

Display relevant indentations (fixes #587)#984

Open
valgarf wants to merge 3 commits into
Wilfred:masterfrom
valgarf:issue-587
Open

Display relevant indentations (fixes #587)#984
valgarf wants to merge 3 commits into
Wilfred:masterfrom
valgarf:issue-587

Conversation

@valgarf

@valgarf valgarf commented May 16, 2026

Copy link
Copy Markdown

This is a proposal to fix #587

It works by adding indent atoms for "indent-aware" languages.
With this change the diff logic has an atom with nonzero length that is actually different.
Changes in indent atoms are shown either as background color or as small colored dots.

Examples

Calls to difft are the previous behavior, calls to cargo run is the new output.

image image

Limitations

When turned on for a language, every line that does not start at column 0 gets an indent atom, even if it is irrelevant.

It is easy to find examples where this is unnecessary:

image

I would argue it is better for a difftool to show an unnecessary whitespace diff than dropping relevant changes, but this could definitely be improved upon. However, my knowledge of the difftastic codebase is limited (I first looked at it 2 days ago). I don't have a good idea on how to change that.

Open Questions

Styling

I currently implemented two styling options, colored dots (my personal preference) and background coloring. Probably only one of those should be kept.

Example with background coloring:
image

Note that background coloring requires less code. The whole DftStyle wrapper around Style is only in the code to replace whitespace with dots.

Languages

Currently enabled for F#, Haskell, Python, YAML, Elm, and Scala.
For Scala it tries to only enable it for version >=3, but if there is no metadata it falls back to enabling it.

Some of the languages in the list I have not even heard about before, so hopefully someone with more knowledge could chime in here.

valgarf added 3 commits May 16, 2026 16:48
adds indent atoms for indent-aware languages.
Shows changes to indent either as background color or as small colored
dots.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Significant whitespace changes (e.g. in Python) are ignored

1 participant