timbrel / GitSavvy

Full git and GitHub integration with Sublime Text
MIT License
1.9k stars 136 forks source link

Feature request: Support staging (add) multiple rows in inline diff #496

Open asfaltboy opened 8 years ago

asfaltboy commented 8 years ago

As can be done with git gui, I would like the ability to "visual select" a range of rows and hit L to stage all of these (but not the entire hunk they may possibly be in.

ZaLiTHkA commented 8 years ago

That would be awesome, I had a few cases just this morning where the ability to stage select lines would have saved me some time.

divmain commented 7 years ago

This will be super hard to add this functionality on top of what we have now. Not impossible, but hard, given the complexity of the code. But I've been considering other ways to abstract away some of the inline-diff complexity, and that may result in a partial rewrite. If that occurs, this is definitely something I'll be keeping in mind. And some intrepid contributor may decide to tackle it in the meantime :)

AllanLRH commented 7 years ago

Would it be easier to implement staging multiple contiguous selected lines? My guess is that that's often the use case, and if several lines from several different hunks needed to be staged, it's still a good amount of time saved.

If one had the have a cursor pr. line, I think that would be all right too, since it's easy to split a selection into cursors... and given that so many other plugin works with multiple cursors, I'd guess it's just some kind of loop over the cursors that's needed? :)

stoivo commented 7 years ago

Inline diff is messy.

Not saying I want. It will give me some headache. It is simpler to stage one select on several lines then each of those lines separately. If we want to allow multiple cursors we should start with the one farthest down in the file, because the we could generate the diff from the closest header.

These lines are the one responsible for staging lines.

CromFr commented 6 years ago

Could be awesome to be able stage a multiline selection at once !

stoivo commented 6 years ago

Why do you want to stage multiple selections on the inline diff? I think it makes more sense to stage one selection but all lines included in the selection.

PR is always welcome

CromFr commented 6 years ago

I meant to be able to stage all lines in a single selection at once, instead of pressing L many times, that often stage unwanted lines.

Something close to this workflow would really be handy: peek 2018-06-26 21-45

I'd love to open a PR myself, but I can barely understand python & don't know much about sublime API :/

randy3k commented 6 years ago

I remember trying to add support for multiline staging. It'll require a partial rewrite of the related codebase. Given that it'll only have a little bit of gain, I am not sure if someone (including myself) would invest time in this matter.

randy3k commented 6 years ago

By the way, this is the related code. Take a look if you are interested in contributing.

asfaltboy commented 6 years ago

@CromFr which editor is that? That looks slick!

For whoever is implementing this. You might want to take a look at git-gui's tcl source code; it's apply_range_or_line proc has a nice large comment about staging multiple lines. It's very similar to what we're doing with applying a patch to single lines, but they continue iterating over all lines in all diff-hunks, creating a large string consisting of the custom patches from selection.

CromFr commented 6 years ago

@asfaltboy This is gitg, I rely on it when I need to stage selectively many lines of a file