Coc.nvim: Errors in floating logic

Created on 31 May 2019  路  9Comments  路  Source: neoclide/coc.nvim

Result from CocInfo

vim version: NVIM v0.4.0-892-gc6cd6081b
node version: v11.15.0
coc.nvim version: 0.0.68
term: xterm-256color
platform: linux

Describe the bug

In the past day I have been experiencing a number of issues where floating windows do not work correctly. E.g. they sometimes move around, don't close, show the previous docs.

Reproduce the bug

This particular bug can be reduced by opening docs and then scrolling a little with your mouse wheel. Notice the location of floating type signature before and after scrolling. scrolling with keyboard works.
Screenshot_20190531_091815
Screenshot_20190531_091843

wontfix

Most helpful comment

Notice the location of floating type signature before and after scrolling

It can't be fixed for now, since there's no scroll autocmd to use.
So my advice is avoid scroll your main window when float window is visible.

All 9 comments

+1. Been having this since I updated my coc.nvim plugin with PlugUpdate today morning. Few things I noticed :

  1. The insert keeps randomly moving away from main buffer to the autocomplete buffer and very often I end up typing in the autocomplete window.

  2. The windows just spawns randomly anywhere. Like seriously, anywhere and doesn't go away from the active buffers and remains stuck in the screen. I have to manually click on the autocomplete window (as I have mouse = a) and then close that buffer with :q. Completely disrupting the workflow.

  3. The autocomplete fails for some reason a lot of times randomly since the newest update of coc.nvim.

  4. The screen flashes every time I type in a character while the autocomplete window is glitching out.

  5. The glitching is random in nature and you either get all the bugs mentioned above or none at all. When you do then the only logical thing to do is to close the session and start a new one, or find all the active buffers and manually kill them else they keep popping up randomly.

Both of these closed tickets are a problem for me :

  1. https://github.com/neoclide/coc.nvim/issues/820
  2. https://github.com/neoclide/coc.nvim/issues/819

From :CocInfo

vim version: NVIM v0.4.0-dev
node version: v8.10.0
coc.nvim version: 0.0.68-4fee42c30c
term: rxvt-unicode-256color
platform: linux

I have lost track of the versions since I have tried updating coc.nvim several times but it was working in the previous version of neovim (about a week old?) and updating the plugin is what broke it. I have since updated my neovim too just in case.

Considering the two closed tickets linked above and @Avi-D-coder and my experiences there is a possibility that a lot more people are probably affected by similar bugs.

@sangeet lots of what you describe looks similar to what I've reported on #819, which fixed the problem for me.

Another thing is that there's a bug in neovim master now that may block it, or cause a segfault. So you may want to use this patch that has not been merged yet:

I think anyone on tip of neovim master will be seriously affected by that bug when getting new diagnostics while code completing.

@Avi-D-coder your description/reproduction-steps are a bit vague, looks like you stripped minimal vimrc for reproduction too. I tried to reproduce your issue but I have to do specific steps, and the behavior is expected. AFAIK, coc.nvim clears up floating windows after a timeout when they get out of context. This timeout exists to avoid clearing it immediately after you put space after a signatureHelp trigger, like comma. For example, if you type foo(41,, you get the signatureHelp for the second argument, but rarely you stop there while typing, you add an additional space foo(41,<space>, so here, coc.nvim could simply clear up the signatureHelp that popped up after ,, or leave it for a moment there, so that it doesn't simply blink when you type. (A smarter solution would be to recognize that foo(41, and foo(41,<space> are semantically identical, but coc.nvim doesn't try to do trim tricks before completing).

In my case, I'm not in general at all able to scroll the source code window when popups are open. This only starts to happen if I scroll inside the floating window first (I could scroll signatureHelp for example), then move the mouse out and scroll the source code.

@sangeet using master instead of releases should fix most of the issues. I am still experiencing some, but it's usable.

@oblitum
Thanks for pointing out the fix to that seg.
Yes my descriptions are vague. With the exception of the scrolling bug, I don't have any way to reproduce these issues, but they are still occurring on up to date master. The new floating logic appears to still be a bit buggy. I will likely take a look at it, but @chemzqm's magic is more likely to fix it.

For the scrolling bug treating mouse wheel down/up like j/k should fix it.

I don't understand your suggested fix. About that bug, IMO, it seems there's primarily a NeoVim issue, for my tests at least. Because NeoVim enables source scrolling _after_ you scroll a floating window once. In Vim and NeoVim, source code scroll can't happen while popups are open, the behavior should be the same before or after you scroll inside a floating window, if it's left open. I'm not sure how a solution to that on coc.nvim's side should be, but ideally it seems the best would be for the popups to vanish immediately if there's an attempt at scrolling outside the popup, so that the NeoVim issue is evaded.

the behavior should be the same before or after you scroll inside a floating window, if it's left open

Because it should behave as a modal window (I think, at least it always behaved like that).

@oblitum Neovim does allow scrolling source with floating windows open. I can scroll source with vista floats and coc floats open, coc just is not closing floats on small scroll wheel events.

Maybe we have different mouse settings?
I have:
mouse="nv"

Notice the location of floating type signature before and after scrolling

It can't be fixed for now, since there's no scroll autocmd to use.
So my advice is avoid scroll your main window when float window is visible.

I've added it to FAQ https://github.com/neoclide/coc.nvim/wiki/F.A.Q#floating-window-position-is-wrong-after-scroll-the-screen.

@sangeet You issue should be fixed by upgrade coc.nvim.

Was this page helpful?
0 / 5 - 0 ratings