lewis6991 / gitsigns.nvim

Git integration for buffers
MIT License
4.91k stars 187 forks source link

No signcolumn refresh after nvim fixendofline adds newline #1023

Open neilord opened 3 months ago

neilord commented 3 months ago

Description

After a newline is added by the fixendofline (new)vim option triggered by saving the file, gitsigns does not update the signcolumn to indicate that change. Only after reopening the file, gitsigns highlight the change on the last line.

Neovim version

NVIM v0.10.0-dev-3097+g064f3e42e

Operating system and version

macOS 14

Expected behavior

Gitsigns does refresh signcolumn after fixendofline adds newline.

Actual behavior

Gitsigns does NOT refresh signcolumn after fixendofline adds newline. Also, the Gitsigns refresh and even Gitsigns detach + Gitsigns attach do not refresh the signcolumn.

Minimal config

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
} 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
}

vim.opt.fixendofline = true
vim.opt.signcolumn = "yes"

Steps to reproduce

  1. Create empty repo: $ cd && mkdir gitsigns_test && cd gitsigns_test && git init
  2. Create file with no newline in the end: $ echo -n 'test' > file
  3. Commit changes: $ git add . && git commit -m 'commit'
  4. Open file with nvim $ nvim --clean -u minimal_lua_path file
  5. Run :w in nvim and see that despite neovim adding newline (because of the fixendofline setting), gitsigns do not show any difference in the signcolumn.
  6. Reopen the file (repeat step 4) to see the signcolumn updated.

Gitsigns debug messages

No response

lewis6991 commented 3 months ago

I found a small bug which I fixed in c96e3cf4767ee98030bff855e7a6f07cfc6d427f but that shouldn't be related.

Otherwise, it seems to work for me.

Can you double check using minimal.lua?

neilord commented 3 months ago

@lewis6991, thanks! Have double checked it with minimal.lua, still not working (see 30 sec below):

bug report

lewis6991 commented 3 months ago

What you are showing in the video is different from the reproductions steps. If the file is committed without an EOF char, then gitsigns should not show a diff upon opening the file.

Can you please update the reproduction steps with exact commands.

Vscode is not relevant here. You can create a file without EOF using:

echo -n 'hello\n'world' > file
git add file
git commit

Also double check if you have a .editorconfig file.

neilord commented 3 months ago

@lewis6991 Got it, thanks! I have updated the Steps to reproduce section in this issue.

lewis6991 commented 3 months ago

Works fine for me.

https://github.com/lewis6991/gitsigns.nvim/assets/7904185/f400c437-71cd-437d-8c71-eab695523c58

neilord commented 3 months ago

@lewis6991, interesting, thanks a lot for taking your time on this one! Will investigate deeper into my setup.

lewis6991 commented 1 week ago

Any updates? Is this still an issue?

neilord commented 1 week ago

Any updates? Is this still an issue?

Unfortunately, it is still not working for me as described in the "Steps to reproduce" with minimal.lua Through if it is working on your machine maybe it is my issue.