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

Feature Request: Unstage Changes on Current Line #1051

Closed
hsayed21 opened this issue Jun 19, 2024 · 9 comments
Closed

Feature Request: Unstage Changes on Current Line #1051

hsayed21 opened this issue Jun 19, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@hsayed21
Copy link

Description

Description

I would like to request a feature that allows users to unstage changes on the current line where the cursor is focused. This functionality would complement the existing stage_hunk, reset_hunk, and undo_stage_hunk functions by providing more granular control over staging and unstaging changes.

Proposed Solution

A new function, unstage_hunk, could be introduced with the following behavior:

  • Unstages changes on the line where the cursor is focused.
  • If the line is part of a hunk, only the changes on that specific line are removed from the staging area, while the rest of the hunk remains staged.

Thank you for considering this feature request. I believe it would be a valuable addition to the gitsigns.nvim plugin, enhancing its utility and user experience.

Neovim version

_

Operating system and version

_

Expected behavior

_

Actual behavior

_

Minimal config

_

Steps to reproduce

_

Gitsigns debug messages

_

@hsayed21 hsayed21 added the bug Something isn't working label Jun 19, 2024
@lewis6991
Copy link
Owner

This is already possible with stage_hunk which toggles the stage status.

@hsayed21
Copy link
Author

I tried it nothing changed in two modes normal or visual

_map("n", "<leader>gs", gs.stage_hunk, "Stage hunk")
_map("v", "<leader>gs", function() gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) end, "Stage hunk")

@hsayed21
Copy link
Author

9qpRWF7XRR.mp4

@lewis6991
Copy link
Owner

You need to pull in the latest changes to include b8cf5e8

@hsayed21
Copy link
Author

Sorry, but I don't understand what I should do. Do you mean I need to update the plugin?

@lewis6991
Copy link
Owner

Yes. Make sure to always have the latest version installed before raising issues on a tracker.

@hsayed21
Copy link
Author

Sorry for not paying attention.
I did the update and it worked, but there's a problem in visual mode where 'unstage' doesn't work

@xzbdmw
Copy link

xzbdmw commented Jul 3, 2024

Yeah unstage does not work in visual mode

                map("v", "<leader>sh", function()
                    gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
                end)

Look at the code, if range is specified the staged hunk does not really caculated, it simply using current line

hunk.added.lines = api.nvim_buf_get_lines(bufnr, top - 1, bot, false)

@lewis6991 this should be reopen?

@lewis6991
Copy link
Owner

@lewis6991 this should be reopen?

That won't fix it. A PR might.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants