Comments (3)
Proposal how to fix this: A hunk in unified diff starts with ^@@
. That line already contains all the information you need: The first number is the line the hunk starts on (irrelevant for you) and the second number (after the comma) is the size of the hunk before (-
) / after (+
) the changes. So from there you count the number of lines starting with
(keep line), -
(remove) and +
(add). Then num_keep + num_remove == hunk_size_before
and num_keep + num_add - num_remove == hunk_size_after
.
So your state machine can be quite dump: You go into a "hunk state" once you reach ^@@
and then read lines until both equations above hold, at which point you have reached the end of the hunk. Then you can do the highlighting of that hunk, output it, leave "hunk state" and search for the next hunk.
For robustness, you should probably also stop when you find a line that does not match ^[ +-]
, independently of how many lines you already read (reason unknown, but you should not care why).
from delta.
Somehow this seems to not have worked. With git config --global diff.submodule log
git diff
outputs:
[...]
Submodule a/b/c a12bc..de34f:
> Commit 2 Message
> Commit 1 Message
[...]
With git config --global core.pager "delta --dark"
I get following output:
[...]
Submodule a/b/c a12bc..de34f:
----
[...]
I.e. the changes to the commits are not displayed any longer.
It thus appears that delta
still mangles lines outside the changed files, in this case also the indented changes to the submodule's commits, which is in "normal diff" format (>
/<
).
from delta.
Hi @fdcds Sorry this second bug has taken so long to fix. I can reproduce it. I notice that a workaround would be to use --file-style plain
or --color-only
, but I agree another fix to the parsing logic is still needed here.
from delta.
Related Issues (20)
- π `ws-error-highlight`
- π Homebrew cannot install from HEAD HOT 2
- π delta fails to run (in some cases) when `git` is not installed
- π White space before 2nd, 3rd `k` shouldn't be in highlighted scope
- π delta not respecting LESS -F environment variable (--quit-if-one-screen) HOT 2
- π Syntax highlighting fails when the visible snippet includes a multiline comment HOT 2
- π error: unexpected argument '--generate-completion' found
- π Treats UTF-16 text files as binary files HOT 1
- π delta causes fancy unicode symbols such as Nerd Font Icons to be displayed as escaped in angle brackets HOT 3
- π Allow asking for full hash of the commit in hyperlinks-commit-link-format
- π A logo for delta?
- π Paths not updated for a diff of modified binary file HOT 2
- RUSTSEC-2024-0013: Memory corruption, denial of service, and arbitrary code execution in libgit2
- π delta won't show diffs of files marked as autogenerated with `.gitattributes` even though they're text files HOT 3
- π Release filename without version HOT 1
- π Mouse scroll not working HOT 1
- Show filename when using `git blame -CCC` π
- Commit hyperlink not working π
- π git-grep path output is often replacing "/" with ":" HOT 1
- RUSTSEC-2023-0081: safemem is unmaintained
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from delta.