lewis6991 / gitsigns.nvim

Git integration for buffers
MIT License
4.86k stars 186 forks source link

Partialy staged hunks are not reported as accurately #1088

Closed ambroisie closed 1 month ago

ambroisie commented 1 month ago

Description

When partially staging a hunk (e.g: only staging the middle line of a 5-line hunk), the whole hunk's sign changes to the "staged" (dimmer) sign.

The unstaged lines should keep their "unstaged" sign, and the staged one the "staged" sign.

A similar problem that I've noticed is when staging a hunk, then modifying it (e.g: staging a 5-line hunk, then adding a line in the middle).

I remember this not being an issue in a previous version of gitsigns.nvim (haven't tried bisecting it yet).

Neovim version

0.10.0

Operating system and version

NixOS unstable

Expected behavior

No response

Actual behavior

Only the middle line (3) has been staged in the following screenshot:

image

It looks like the whole hunk has been staged.

I would expect to instead have 2 "unstaged" (bright green), one "staged" (dull green), and two "unstaged".

Minimal config

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
} do
local install_path = vim.fn.fnamemodify('gitsigns_issue/'..name, ':p')
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
end
vim.opt.runtimepath:append(install_path)
end

require('gitsigns').setup{
  debug_mode = true, -- You must add this to enable debug messages
  -- ADD GITSIGNS CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
}

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE

Steps to reproduce

  1. git init test
  2. cd test
  3. Emulate partial staging:
    1. echo '3' > test
    2. git add test
    3. printf "1\n2\n3\n4\n5\n" > test
  4. nvim test

Gitsigns debug messages

No response

Gitsigns cache

No response

gegoune commented 1 month ago

Is it the same as #929?

ambroisie commented 1 month ago

@gegoune ah yes thank you, I'd tried searching for it but didn't find it. Closing as dupe.