Skip to content

Diff view #396

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

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

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.

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
@fstachura fstachura force-pushed the diff branch 2 times, most recently from f76cccc to 3244c34 Compare April 11, 2025 21:59
@fstachura fstachura force-pushed the diff branch 3 times, most recently from c105230 to ce871ec Compare May 29, 2025 11:30
@fstachura fstachura marked this pull request as ready for review May 30, 2025 17:24
@fstachura fstachura changed the title WIP: Diff view Diff view May 30, 2025
@fstachura
Copy link
Collaborator Author

I think it's more or less done. I'm not sure if identifier links and search should redirect to the diff or to the target version.

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