chrisgrieser / nvim-tinygit

A lightweight bundle of commands focussed on swift and streamlined git operations.
MIT License
170 stars 5 forks source link

feat: interactiveStaging multiselect support #16

Closed al-ce closed 3 months ago

al-ce commented 3 months ago

Checklist

Changes

Toggle the staging status of hunks selected with Telescope multi select

staging

Reset multiple hunks with Telescope multiselect. If no hunks remain, close interactiveStaging picker (gif doesn't reflect this feature)

resetting

chrisgrieser commented 3 months ago

I am not sure I understand how this PR is needed. Since staging does not close the window, it is effectively already a multi-select?

al-ce commented 3 months ago

My initial reason for implementing was that in insert mode I'm not very comfortable repeatedly scrolling and selecting. Even with using ctrl-n/ctrl-p then space (or any other sensible toggling key) or my homerow arrow layer, the switch back and forth is awkward in my keyboard layout. I didn't want to configure special Normal mappings or timeouts for TelescopePrompt filetypes.

Telescope's multi-select automatically moves the cursor down to the next row after making a selection, and I can perform the staging/resetting action with one keystroke at the end (e.g. in a 6 hunk review, 7 keystrokes instead of 12 and no awkward finger-dances). I realize it might be over-optimization, but I like to avoid discomfort to keep me focused.

Additionally, I like that I can review everything as I select and have more context before I make the decision to stage or reset. In particular, currently I can't undo resets until going back to the file's buffer. The main advantage of selecting everything first is that I can review every hunk and make a more informed holistic decision before I actually reset, marking any hunks for re-consideration with the easy to find + symbol. Preventing an accidental reset is also a nice bonus.

That said, it's a fair point that the current picker is pretty much a multi-select already, and I understand that adding these changes might not be worth the loss of simplicity. Just wanted to answer the question of purpose thoroughly, and thanks for considering. I think closing the picker once the hunks table is empty could still be a nice idea.

chrisgrieser commented 3 months ago

Additionally, I like that I can review everything as I select and have more context before I make the decision to stage

That way of thinking feels a bit off to me, since in my mental model for git, staging is selecting hunks that you later on "confirm" by performing a commit. So to me, what you are doing sounds like making a selection for what is to be selected.

You can just unstage by pressing space again, so the current feature-set already works fine for this.

That said, it's a fair point that the current picker is pretty much a multi-select already, and I understand that adding these changes might not be worth the loss of simplicity.

Yeah, tbh, this PR feels a bit like overengineering it, so I am closing this.


Telescope's multi-select automatically moves the cursor down to the next row after making a selection

That one is actually a good idea, I added an opt-in feature to have the cursor move down when toggling staging.

I think closing the picker once the hunks table is empty could still be a nice idea.

Yeah, I think this is actually a good idea for an opt-in feature. I am open for a PR for that.

chrisgrieser commented 3 months ago

I think closing the picker once the hunks table is empty could still be a nice idea.

Yeah, I think this is actually a good idea for an opt-in feature. I am open for a PR for that.

Thinking about it, I am actually not sure about this one. All this would do is to save you from pressing esc once at the end? 🤔