Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff: highlight word-level changes in git diffs #4007

Merged
merged 2 commits into from
Jul 5, 2024

Conversation

yuja
Copy link
Collaborator

@yuja yuja commented Jul 2, 2024

default style:
image

with bg color:
image

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@joyously
Copy link

joyously commented Jul 2, 2024

I can't see the underscores with the underlines.
How is that second image using bg color? I see only black bg.

@yuja yuja force-pushed the push-zotnspxzmtnm branch 2 times, most recently from 61ce79b to 4b4c722 Compare July 4, 2024 23:08
@martinvonz
Copy link
Member

I can't see the underscores with the underlines.

I agree they're not easy to see. Try zooming in a bit.

How is that second image using bg color? I see only black bg.

Only modified parts, such as the added use line, use background color.

Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

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

Seems useful!

cli/src/diff_util.rs Show resolved Hide resolved
yuja added 2 commits July 5, 2024 15:52
I'm going to add word-level highlighting there.
The output looks somewhat similar to color-words diffs. Unified diffs are
verbose, but are easier to follow if adjacent lines are added/removed + modified
for example.

Word-level diffing is forcibly enabled. We can also add a config knob (or
!color condition) to turn it off to save CPU time.

I originally considered disabling highlights in block insertion/deletion, but
that wasn't always great. This can be addressed separately as it also applies
to color-words diffs. jj-vcs#3958
@yuja yuja force-pushed the push-zotnspxzmtnm branch from 4b4c722 to 8647454 Compare July 5, 2024 06:55
@yuja yuja merged commit 44a3901 into jj-vcs:main Jul 5, 2024
17 checks passed
@yuja yuja deleted the push-zotnspxzmtnm branch July 5, 2024 07:07
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.

3 participants