Display relevant indentations (fixes #587)#984
Open
valgarf wants to merge 3 commits into
Open
Conversation
adds indent atoms for indent-aware languages. Shows changes to indent either as background color or as small colored dots.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
difftare the previous behavior, calls tocargo runis the new output.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:
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:

Note that background coloring requires less code. The whole
DftStylewrapper aroundStyleis 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.