-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Undo deprecated? #1180
Comments
It is implemented and those keymaps should work. I use it all the time. |
How do you use them? After mistakenly staging a hunk, what do you do? Running |
You need to have staged signs enabled and you need to run |
I also just stumbled over an issue here, but only in visual mode. In normal mode it works as expected. However in visual mode it does not. Only if the upmost line has a change, it works. I also found adjusted config in the README: map('v', '<leader>hs', function()
gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') })
end) But this only works to stage an area, not for un-staging. |
Hi, I'm also using gitsigns daily and I find it amazing, thanks a lot! |
Thanks @lewis6991, I just tried the @spreiter Do you want to unstage just a part of a hunk? |
No, I was actually trying to unstage 2 hunks at once. I tested now the following in visual mode:
All done with the keybinding from the README file: '<leader>gs',
function()
require('gitsigns').stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
end,
mode = 'v', |
@h0adp0re It's hard to make everyone happy, but I don't want to be maintaining features that roughly achieve the same thing. |
@spreiter the logic for how staging works is fairly straightforward. So straightforward, I can just paste the code. local hunk = get_hunk(bufnr, range, opts.greedy ~= false, false)
local invert = false
if not hunk then
invert = true
hunk = get_hunk(bufnr, range, opts.greedy ~= false, true)
end
if not hunk then
api.nvim_echo({ { 'No hunk to stage', 'WarningMsg' } }, false, {})
return
end
local err = bcache.git_obj:stage_hunks({ hunk }, invert)
if err then
message.error(err)
return
end Gitsigns will first attempt to find a hunk (using range is supplied) by looking at unstaged signs. If no hunk can be found/created, it will try looking at staged signs. |
Yes, I checked it out. On the first glance it looked fine to me. I am not sure, what exactly is going wrong. Also in the I added some {
added = {
count = 5,
lines = { " # 1", " # 2", " # 3", " # 4", " # 5" },
start = 311
},
head = "@@ -308,5 +311,5 @@",
removed = {
count = 5,
lines = { " # 1", " # 2", " # 3", " # 4", " # 5" },
start = 308
},
type = "change",
vend = 315
} I would need more time to fully understand, how it works.. |
I think I understand the issue. The problem is in To do this correctly:
|
Only when a hunk is partly staged and I try to un-stage in normal mode on a staged line, nothing happens, not even a message. If I stage the not staged line, it gets staged correctly. But I think this is a quite rare occasion 😉 Thanks for the update and sorry for injection into this issue. |
If anything doesn't work, and you want it to, then please raise an issue report with precise information. |
Hello! First, thank you for maintaining this plugin, it's part of my daily Git interface.
A feature I frequently rely on is
undo_stage_hunk
. Recently, it was deprecated with the note "usegitsigns.stage_hunk()
on staged signs". I tried to do that but I'm only getting the message "No hunk to stage" in my work buffer. These are my current keymaps:Is the replacement feature not implemented yet? Or is this feature (as-is) going away?
The text was updated successfully, but these errors were encountered: