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

WIP: Diff view #396

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

WIP: Diff view #396

wants to merge 7 commits into from

Conversation

fstachura
Copy link
Collaborator

@fstachura fstachura commented Mar 5, 2025

Note: this is work in progress, not ready for review. Comments are welcome, but I don't expect a full review just yet. Mostly posting this to show that there is some slow progress on this feature.

Right now, the feature only supports a split diff view. This neatly solves the "which version should an identifier link to" problem.

TODO:

  • Identifiers popup is not aware of the diff view at all
  • Coherent interface - right now you need to first visit a file, then check "diff mode", then select a version from the sidebar
  • Linking to lines doesn't work
  • CSS is still slightly broken

How the diffs are generated:

  • Take sources of a and b, put both of them through the tokenizer and initial filters
  • Take a diff of a and b in a special format (see get_diff in script.sh) that basically only shows where to add empty lines, and which lines to mark as added/deleted
  • Pass sources of both files to a subclass of Pygments's HtmlFormatter, that adds empty lines/colorizes lines based on the diff information.

There is a slight efficiency problem with this approach - files can be very similar, but both will get tokenized and formatted separately. And IIRC formatting can take a lot of time.
I don't see a good way of solving that, maybe something smart could be done with the lexer/formatter.
The only optimization that could be worth it, is caching identifiers looked up in the first file for the second file (not implemented yet, and I don't know if it would make sense). I think it would also make sense to limit the size of diffed files - no one should do diffs on the 20 megabytes amdgpu register definitions.

Closes: #25

@fstachura fstachura mentioned this pull request Mar 5, 2025
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.

Missing diff option
1 participant