-
Notifications
You must be signed in to change notification settings - Fork 393
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
🚀 Highlighting of --word-diff output, and custom "squashed" diff output #152
Comments
In a quick check - no. Would be awesome to add though. |
diff --word-diff
?
Hi @ryanberckmans (and @AvnerCohen), thanks for this! Could you expand on exactly what you'd like to see here? In a sense Delta does provide something like |
Are you thinking of replacing git's default (and ugly)
|
How about something like: _SUPPORTED_PYTHONS = [ With relevant color scheme applied as well ? What would be nice is if the color is applied not across all lin, but just on the +- parts. |
@AvnerCohen could you comment on how you see the role of delta's default within-line edit highlighting versus Again, I'm not suggesting we shouldn't support Git's |
@dandavison Thanks for the time and effort. |
@dandavison to answer your question on what I'd like to see here- Simply put, right now delta doesn't seem to support In this screenshot, I'd expect the removals and additions to be styled according to the configured delta theme. Right now they are unstyled. Thanks! |
Thanks @ryanberckmans. I agree that that would make much more sense and that, whatever features delta offers, people will still send it Out of interest, do you have any comments on when you use
|
@dandavison delta's within-line edit highlighting displays on two lines, whereas |
At the very least I'd love to see |
@dandavison I would like to have this feature and help coding it. Could you give me some guidelines where to start? |
Hi @pilif-pilif, thanks for the offer! Let's start thinking about this then. I think that we need to start off with some design thinking before getting to code changes. Basically, what exactly are we aiming for? One question is:
Syntax highlighting might be quite hard: I think we would have to parse the input to reconstruct the original minus/plus lines of valid syntax in the target language, send those to the syntax highlighter, and then recombine them. Honestly, after writing the notes below, I am starting to wonder about a different approach here: maybe we should just emit the What are your initial thoughts about how you want this to behave when you are finished with it? Here are some more notes. I'm just writing down my initial thoughts, so I am probably overlooking possibilities. Here is some raw output from We see that
Now, here is the same output, but using delta: We see that
The |
Hi @dandavison, sorry for the delay. I think that When I use a squashed diff I want to see fast what changed where and in what environment/segment. So so maybe delta can:
what do you think? |
Hi @pilif-pilif, Two questions
The behavior here will depend on the sublime syntax definition for the language in question so I think all we can say is that the syntax highlighting behavior is undefined/unpredictable: it may change it, and as the example above showed a comment can confuse it. So I'm not sure that I have a better suggestion than adding a new option to delta that causes it to emit the affected lines in raw mode throughout the entire line. Perhaps that new option is not specifically related to |
Hi @dandavison, 1, I think it would be sufficient to have s.-highlighting on the surrounding lines only. That way the
I want to check my logic - please correct me if I am wrong: (I know the ".." part is very abstract formulated)
can delta influence directly the syntax highlighter prosses? |
Yes, that's basically accurate. As you say, delta saves a copy of the input line with ANSI color codes stripped and also saves the raw line with ANSI codes intact. Then, in the main state machine parser loop delta calls I think that you are going to want to write a new version of Lines 458 to 525 in a4f5a4f
As you can see it's basically a match statement handling the 3 cases: minus, zero, and plus. These are recognized by a
Here's the code location downstream where we see delta not syntax-highlighting line that should be emitted "raw" (the fact that is should be emitted "raw" is represented by the enum instance containing a non-empty value. In fact the data contained by the enum is the raw line characters.) Line 456 in a4f5a4f
So hopefully that helps a bit. I'm going to add some more thoughts in a separate comment. |
cc @th1000s just in case you have any thoughts: the topic here is git's It seems to me that there are two related objectives: (a) Handle So far we have been talking as if the new feature would do (a) and (b) so that a user who enters But another way of approaching this would be to
This way a delta user would be able to select single-line squashed diff output whether or not they had passed |
On a), handling the input: Detecting unified diff vs. word diff format is probably not that difficult, when a hunk contains no And b), unless I misunderstand the issue, should just be the standard red/green background. 2.) Sounds much better, only the |
Thanks for linking me here @dandavison and apologies for my delay. As is often the case various things take priority over tinkering with tools but every time I get back to tools I am reminded that it's the foundation for my success. I'm grateful for the ground that has already been covered on these topics here, and I would like to contribute from a few directions: My personal experience with an independent diff input formatI fell down the rabbit hole of enhanced line diffs on the command line ever since I caught a glimpse of intra line highlighting via things like You may see in the above linked discussions #776 #785 where I have posted screenshots, my tool is fundamentally pretty similar to git One of the many deficiencies that I wanted to address with stuff like diff-highlight (and which I perceived on cursory evaluation of other options, and I might add this applies to github as well is that the results are sort of suboptimal in the sense that no effort is put toward bringing out a lot of the details in intra-line changes. For example please compare the quality of highlighted regions between (assume the usual where + line is green and - line is red) and As you might imagine I have become rather reliant on these maximally concise diffs where there are several main optimal properties:
So far I've never had a need for changing the behavior of this from doing a kind of brute force character-wise diff. I have not had a chance to more deeply explore Now computing a character-wise diff does increase computational load compared to regular diff implementations and I use it for almost, but not all, git diff viewing scenarios: I keep aliases around to use lesser, much faster diffs, and use them often when engaging in deep archaeology sessions because the runtime of All of this to say, I have a unique perspective on this issue of "squashed-diff" output, I come bearing a third possible input to Delta, and am strongly in support of having flexibility of input for Delta so that I may apply it to my own needs. I want to be able to use all diff tools at my disposal in git, and I've described (unfortunately not very concisely) the delightful extent of the benefits inside and outside of git that can be had from dedicating a little more compute to diff calculation. I feel that Delta has independently gone down the same path in this regard, to great effect and with a much more efficient implementation. When I consider choosing between using Delta or So, the point I want to make (and finally coming back to the topic at hand): word-diff is often more concise and readableIt's clear to me now that I have been driving Delta for a few weeks that its only weaknesses compared to my beloved
On syntax highlighting of concise/squashed diff outputI am not sure if there was a consensus regarding whether/how to highlight the squashed diff lines. I think the minus and plus sections themselves never have ambiguity in their syntax. They should just be highlighted per their computed values based on the minus- and plus- reconstructed hunks. It is the context lines that have ambiguity. This is, after all, why I believe we need to consider even in the squashed-diff mode we're proposing, that we may still want to have a configurable mode where if the syntax in the unchanged context would be different that we should show the minus- and plus- unchanged context content. A simple example of this is if some lines become commented. They turn from code syntax to comment syntax. I know what I would like to do to view these scenarios is I would like to see both versions of diff, squashed to make it easier to see all of the chars changed only (i'd do it today with Misc. (somewhat off topic but might help someone who has gone off the deep end like me)I've found it difficult ever since I discovered Delta recently, to toggle between 3 ways to view git diff,
The issue I was running into was that if I configure an external diff ( In conjunction with this, since this issue means that I cannot use a I just did some testing and was able to find the workaround! |
The current release (0.10.3) refuses to handle |
Note dandavison/delta#152 is causing a (small) change in that WS intendation is no longer ignored, but it's still possible to use git diff -w. PS: I also considered https://github.com/so-fancy/diff-so-fancy but opted for delta after reading https://dandavison.github.io/delta/features.html and seeing https://dandavison.github.io/delta/comparisons-with-other-tools.html
|
I'm not aware of a bug like this. @vigo if this is something that you can repro it would be great if you could post the input to delta that causes this error. |
@dandavison ooh man, i don't remember right now :) it's been months :) i'll send if this occurs again. |
Does delta support
diff --word-diff
?The text was updated successfully, but these errors were encountered: