airblade / vim-gitgutter

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.
MIT License
8.37k stars 297 forks source link

Blank screen after starting neovim #589

Closed stinovlas closed 5 years ago

stinovlas commented 5 years ago

What is the latest commit SHA in your installed vim-gitgutter?

5c8efd3625b7f5a586ad3ce5922ad45ae5661393

What vim/nvim version are you on?

I use neovim nightly builds, currently on 0.4.0+ubuntu1+git201903032022-bcbb96e-eada8be-ddff4c8~ubuntu18.04.1

I experience strange bug. When I start nvim file.txt, I get totally blank screen and even if I press some keys, the screen remains blank. Only after I press Ctrl+C, I get control of neovim. After that, vim-gitgutter signs are visible and working correctly. When I run :messages, I don't get any output. This problem does not manifest when I run

I tried to disable all my plugins one by one, and the only one that seemed to cause the trouble was vim-gitgutter. If I disable this plugin, neovim starts as expected. I'd like to continue using vim-gitgutter, but this behaviour is really annoying. Any ideas what to do about it?

airblade commented 5 years ago

You could try let g:gitgutter_log=1 in your init.vim, then start nvim, get control, and quit. The log file will be in the directory where vim-gitgutter is installed.

stinovlas commented 5 years ago

Wow, that was quick, thank you! This is the logged output:

On tracked file:

==== start log session ====

  0.000014 function <SNR>16_on_bufenter[5]..gitgutter#init_buffer[4]..gitgutter#utility#set_repo_path[11]..gitgutter#async#execute[1]:
  0.000014 [async] cd /home/jmusilek/.config/nvim/plugged/vim-gitgutter && git ls-files --error-unmatch --full-name -z -- README.mkd

  1.144796 function gitgutter#process_buffer[8]..gitgutter#diff#run_diff[83]..gitgutter#async#execute[1]:
  1.144796 [async] cd /home/jmusilek/.config/nvim/plugged/vim-gitgutter && (git --no-pager show :README.mkd > /tmp/nvimHsTOvU/2.1.1.mkd && git --no-pager  -c "diff.autorefreshindex=0" -c "diff.noprefix=false" -c "core.safecrlf=false" diff --no-ext-diff --no-color -U0  -- /tmp/nvimHsTOvU/2.1.1.mkd /tmp/nvimHsTOvU/3.1.1.mkd | grep '^@@ ' || exit 0)

  1.172653 function <SNR>135_on_exit_nvim[2]..gitgutter#diff#handler[1]:

On untracked file:


  0.000013 function <SNR>16_on_bufenter[5]..gitgutter#init_buffer[4]..gitgutter#utility#set_repo_path[11]..gitgutter#async#execute[1]:
  0.000013 [async] cd /home/jmusilek/.config/nvim/plugged/vim-gitgutter && git ls-files --error-unmatch --full-name -z -- empty.txt

 63.494237 function gitgutter#process_buffer[10]:
 63.494237 Not tracked: /home/jmusilek/.config/nvim/plugged/vim-gitgutter/empty.txt

 63.494563 function gitgutter#process_buffer[17]..gitgutter#diff#handler[1]:
 63.494563 
stinovlas commented 5 years ago

When I downgrade neovim to 0.3.1-3ppa1~ubuntu18.04.1, this issue is not appearing anymore. Maybe this is a bug in neovim itself?

airblade commented 5 years ago

Thanks for the logs. It looks like gitgutter kicks in straightaway but that first async job takes a suspiciously long time to call back. Presumably the job cannot call back until neovim is unfrozen?

I would suspect a bug, or if not a bug an unfortunate change, in neovim. Is there a way to browse the commits between those two releases, or even better to bisect them?

stinovlas commented 5 years ago

I would suspect a bug, or if not a bug an unfortunate change, in neovim. Is there a way to browse the commits between those two releases, or even better to bisect them?

I'm afraid that I'd need to build neovim from source. I can do that, but it'll take some time that I don't have right now. I'll let you know when I get to it.

tacho commented 5 years ago

I did some digging, as I have the same issue.

For me, it only happens on a Mac, and only when using iTerm. I use iTerm nightlies, currently at 3.3.20190304-nightly.

I get the blank screen after - and including - Neovim commit 246408621c405a6c0f24e2e5cd66e8776eb04fe6 (Merge #9509 'TUI: detect background color'), which tries to query the terminal about its background color.

I don't fully understand the sequence of events, but it seems like some race condition to me. Even after this patch, if I open just Neovim and then open a file - GitGutter works fine. If I directly try to open a file by giving it as a command line argument - Neovim hangs in GutGutter, as described above. It will eventually show up the contents of the file though, and will work fine. But that could take upwards of a minute. If GitGutter is removed, everything works.

Everything works in Terminal.app. It breaks for me in iTerm and in Kitty. On Linux it works fine on Konsole and Kitty, but I haven't tried others.

So, I don't think the issue is with GitGutter per se. I've opened a Neovim issue on the matter - https://github.com/neovim/neovim/issues/9675

airblade commented 5 years ago

@tacho Thank you, that's really helpful.

blueyed commented 5 years ago

The Neovim issue has some patch by now.

And just for information, the following would fix it for gitgutter also, since it avoids the "polling via sleep" that triggers this: https://github.com/airblade/vim-gitgutter/pull/593

airblade commented 5 years ago

@blueyed Thanks!

I'm going to close this now because neovim has been patched. I'll take a look at #593 separately.

airblade commented 5 years ago

This should be fixed in gitgutter as of 064a3d6.