Closed kofls closed 4 years ago
Hi @kofls, thanks for this. You're right, this is definitely a problem. This is actually a duplicate of #117 (but it didn't have a very helpful title so not surprising you didn't find it; I just changed the title). So -- the question is -- do you have any ideas about how we should address it?
Hi @dandavison, Sorry for the duplicate. I looked through the open issues but not well enough I guess. You can close this issue then.
I think a simple solution would be to get the syntax style per file and use that for each diff section. Not sure how expensive that would be but no doubt it would be slower than the current implementation. If it is significantly slower, maybe this could be enabled by a flag and the default behavior be left as is.
There probably is a smarter way to do this by only calculating the syntax style for a part of the file. For the python example, getting the syntax style for the above and below classes from the diff line should be enough to correctly highlight the diff. But in general, I have no idea how this subsection can be identified.
Thanks! I replied to you in https://github.com/dandavison/delta/issues/117#issuecomment-687281613 so as to keep the conversation in one place.
Syntax highlighting seems to be considering the diff chunk independent to the rest of the file and sometimes results in highlighting like:
Here, the function is highlighted as a comment instead of the two surrounding comments.
Example code:
git --no-pager diff
:delta --version
:delta 0.4.1
delta --show-config
: