lewis6991 / gitsigns.nvim

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

bug: `gitsigns.nvim` makes Neovim randomly freeze when scrolling/switching buffers #1029

Closed pidgeon777 closed 3 months ago

pidgeon777 commented 3 months ago

Description

Occasionally, while scrolling or switching between buffers, Neovim unexpectedly becomes unresponsive. When this happens, I am forced to manually terminate the nvim.exe process.

This behavior started manifesting approximately two weeks ago.

Neovim version

NVIM v0.10.0

Operating system and version

Windows 11 Version 23H2

Expected behavior

No freezes should occur.

Actual behavior

Neovim freezes when randomly scrolling and switching buffers.

Minimal config

I can't reproduce it with this basic config:

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/LazyVim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Instead, I'm able to reproduce it using the plugin directly in LazyVim.

But, if I disable gitsigns.nvim in LazyVim using this plugin spec:

return {
  {
    "lewis6991/gitsigns.nvim",
    enabled = false,
  },
}

then everything works fine, with no freezes.

Steps to reproduce

  1. Install basic LazyVim distribution.
  2. Open several tabs in Neovim.
  3. Rapidly alternate between them in no particular order.
  4. Swiftly scroll through the open buffers.

Gitsigns debug messages

Can't get it, given that Neovim freezes.

pidgeon777 commented 3 months ago

Maybe it could be related to this:?

https://github.com/LazyVim/LazyVim/discussions/3407

https://github.com/lewis6991/gitsigns.nvim/issues/1027

lewis6991 commented 3 months ago

Can this be reproduced without LazyVim?

I don't want to spend time debugging someone else's code.

RichardEpure commented 3 months ago

I also find that neovim sometimes freezes when gitsigns is enabled and you try to quit via :q or :qa. But it consistently does so when switching sessions via something like rmagatti/auto-session (can be any session plugin, I've tried multiple) from one repo to another and then trying to quit.

I'm on the same version of neovim and windows.

@pidgeon777 Do you experience the same? Curious if it's related or perhaps just a separate issue. I did try a minimal config with just gitsigns & autosession installed and the same thing happens.

lewis6991 commented 3 months ago

Sounds the same as #1027

lewis6991 commented 3 months ago

Is this fixed with #1031?

pidgeon777 commented 3 months ago

This:

https://github.com/lewis6991/gitsigns.nvim/pull/1031

and maybe also this?:

https://github.com/lewis6991/gitsigns.nvim/commit/e31d2149d9f3fb056bfd5b3416b2e818be10aabe

seems to have solved the issue.

I also find that neovim sometimes freezes when gitsigns is enabled and you try to quit via :q or :qa. But it consistently does so when switching sessions via something like rmagatti/auto-session (can be any session plugin, I've tried multiple) from one repo to another and then trying to quit.

I'm on the same version of neovim and windows.

@pidgeon777 Do you experience the same? Curious if it's related or perhaps just a separate issue. I did try a minimal config with just gitsigns & autosession installed and the same thing happens.

I had the same issue, now seems to be solved. Are you still experiencing this?

RichardEpure commented 3 months ago

This:

1031

and maybe also this?:

e31d214

seems to have solved the issue.

I also find that neovim sometimes freezes when gitsigns is enabled and you try to quit via :q or :qa. But it consistently does so when switching sessions via something like rmagatti/auto-session (can be any session plugin, I've tried multiple) from one repo to another and then trying to quit. I'm on the same version of neovim and windows. @pidgeon777 Do you experience the same? Curious if it's related or perhaps just a separate issue. I did try a minimal config with just gitsigns & autosession installed and the same thing happens.

I had the same issue, now seems to be solved. Are you still experiencing this?

Nope. It's fixed now for me since #1031.

pidgeon777 commented 3 months ago

Perfect. Thank you for the great fix @lewis6991! 👏