Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle stage hunk #788

Open
axieax opened this issue May 1, 2023 · 6 comments
Open

Toggle stage hunk #788

axieax opened this issue May 1, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@axieax
Copy link

axieax commented May 1, 2023

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

When I accidentally stage the hunk my cursor is under, it's frustrating that I can't use the same keybind / command to toggle the staged status of the hunk. I know that undo_stage exists, but it's on a separate keybind, and I couldn't find a way to make a custom mapping which performs one of the actions based on whether the current hunk is staged or not.

Describe the solution you'd like
A clear and concise description of what you want to happen.

A hunk_toggle_staged action which stages the hunk under the cursor if unstaged, and vice versa.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Registering a custom command; using the cmdline to find out whether the current line is staged.

Additional context
Add any other context or screenshots about the feature request here.

@axieax axieax added the enhancement New feature or request label May 1, 2023
@ivan-volnov
Copy link

Great idea! I would change it a bit to a line_toggle_staged, not whole hunk

@hinell
Copy link

hinell commented Oct 5, 2023

It's gonna be tricky to implement. Git doesn't keep track of hunks staged. It's a pile fo staged hunks for a given file only.

@lewis6991
Copy link
Owner

Gitsigns can already track staged hunks if you set _signs_staged_enable = true in setup(). It works by running an extra diff against HEAD and subtracting the hunks.

@leiteg
Copy link

leiteg commented Apr 11, 2024

@lewis6991 Is there any particular reason for this option to not be documented?

@lewis6991
Copy link
Owner

Because it isn't finished.

@leiteg
Copy link

leiteg commented Apr 11, 2024

Fair enough!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants