Comments (7)
The command that is used to get the diff is git diff -U0 --no-color
which in your example would produce output like
diff --git a/t b/t
index 7898192..c30627b 100644
--- a/t
+++ b/t
@@ -1 +1,12 @@
-a
+a,
+b
+b
+b
+b
+b
+b
+b
+b
+b
+b
+b
The part specifically that we look at is @@ -1 +1,12 @@
This basically means that this hunk of changes originally started at line 1 and occupied 1 line, it now starts at line 1 and occupies 12 lines. There isn't much data in that bit to determine which of those 12 lines are new/modified so it counts the whole hunk as modified.
You theoretically could probably parse the extra bit at the end of the output to determine this, but it would be complex, and this operation needs to be done with performance in mind since it is runs live as you type each character.
from gitgutter.
Awesome, thanks for the crystal-clear explanation of how it works.
Do you know if it's possible to know which line in the diff output maps to which line in the working buffer?
I can tell from looking through some diffs with -U0
the format basically puts the line number, and what comes after the comma is the count of lines added or removed, with the shorthand of omitting the comma and second number if the second number is 1 (i.e. one line removed or one line added). I don't need to explain that to you since this plugin clearly works great as-is. So this means we know for each "group" how many are added and how many are removed.
So if we can just do an O(n) scan (where n is # lines) through the rest of the output there, only looking at the very first character (remember, parsing through all this output, just to find each @@ @@ header, means this operation is already O(n) runtime) we can construct our totally correct sequence of markers (which will be not all "Modified" markers!). Only we'll be assembling an extra list of markers there. Not that such a list isn't probably being constructed now, anyway.
I think I know what I'll do during off-time at work tomorrow :D They're still stuck in the dark ages with Perforce.
from gitgutter.
Unfortunately I think this means that a deleted line could now be adjacent to a modified or inserted line, and that means the deletion top and bottom markers must now be multiplexed with the other icons. That's 4 additional icons!
It would be really cool, but considering how little of the code I can understand now after looking it over, I unfortunately cannot dig into it now.
from gitgutter.
You could avoid the icon thing by parsing the modification blocks and only adding the appropriate insert icons and treat removed lines as is. But yeah, I am currently satisfied as is, and don't really feel compelled to dig into that right now either.
from gitgutter.
Check it out, I took the sledgehammer approach to this piece of the git workflow.
from gitgutter.
@unphased are we good to close this?
from gitgutter.
Sure... plugin works fine, really.
from gitgutter.
Related Issues (20)
- Inline commit log message and file types HOT 2
- GitGutter not available to install in package control HOT 4
- How do I make the icons show? HOT 2
- Gutter icon too small HOT 1
- How to disable key bindings? HOT 1
- 'NoneType' object has no attribute 'set_timeout' HOT 1
- AttributeError: 'NoneType' object has no attribute 'replace'
- I can't see any information on sublime 4100 HOT 1
- Allow formatting of line_author_time HOT 1
- ST4 - config "show_line_annotation" not working HOT 4
- What is supposed to be insert icon instead is modify icon. HOT 1
- Sublime Text 4 support, please HOT 12
- feature: command to copy commit_id from line annotation and hyperlink commit id to external git client HOT 2
- Compare against branch indicates no changes and differs from "git diff <branch>" HOT 4
- Not work for network mount wsl2 disk HOT 2
- Files in cloned gists don't show the inline git blame when `show_line_annotation` is set to `true` HOT 2
- `~` is not accepted/resolved to home in `git_binary` HOT 3
- 1.11.8 can not work in ST4 with win11. HOT 5
- GitGutter is throwing errors related to mdpopups and not working HOT 2
- Change font on popups HOT 5
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 gitgutter.