neoclide / coc-yank

Yank highlight and persist yank history support for vim
188 stars 8 forks source link

Highlight issue in vim8 #6

Closed linjiX closed 5 years ago

linjiX commented 5 years ago

This plugin makes some highlight issue and error message in Vim8 And it works fine in Neovim

Issue:

  1. Below error message appears when yank or enter visual mode
    [coc.nvim] error: error on notification 'doAutocmd': SyntaxError: Unexpected token / in JSON at position 130482
  2. The yank highlight will not disappear automatically until the moving the cursor
  3. Moving cursor in visual mode will make a mess with the highlight in the screen

vim --version

VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 20 2019 14:46:15)
Included patches: 1-1575
chemzqm commented 5 years ago

What's your system? I can't reproduce on Mac and windows.

linjiX commented 5 years ago

I use Ubuntu16.04

chemzqm commented 5 years ago

Can't reproduce on vim 8.1.1477 with Ubuntu16.04, try upgrade your coc.nvim.

linjiX commented 5 years ago

I upgrade my coc, but the issue still exist.

I create a minimal reproduce environment which remove all other vim plugins and coc plugins and a empty coc-settings.json. node --version v10.16.0 Minimal vimrc:

set nocompatible set nobackup

call plug#begin('~/.vim/plug') Plug 'neoclide/coc.nvim', {'branch': 'release'} call plug#end()

filetype plugin indent on syntax enable syntax on

linjiX commented 5 years ago

And I found that the error message will also appear in Neovim when yank. And all other things works fine in Neovim

BodneyC commented 5 years ago

For me, my yank history ($HOME/.config/coc/extensions/coc-yank-data/yank.json) had become corrupt, ending with an additional ]}].

Deleting this solved the problem; doesn't fully solve the issue but it's a temporary fix.

linjiX commented 5 years ago

@BodneyC Yes, remove yank.json does fix the error message temporary. I also tried to reproduce this issue in my environment. Here is what I found:

  1. In Vim8, the text I selected in visual mode will be considered as yanked in coc-yank. In other words, the content I selected in visual will be writed into yank.json. Which will not happen in Neovim.
  2. In Vim8, enter visual mode first, then scroll the screen very fast (like continue pressing ctrl+d), the error message appears again and the yank.json is corrupted.

Hope it helps.

chemzqm commented 5 years ago

The json file is written on TextYankPost, so maybe something wrong with trigger of autocmd on your vim.

I can't reproduce with my vim, no change of yark.json after enter visual mode or scroll.

linjiX commented 5 years ago

I think I found the root cause: TextYankPost and visual selection causes spurious syntax highlights I is a vim issue about TextYankPost. I may skip this plug until it is fixed

Thanks

mawkler commented 5 years ago

I have the same problem.

Whenever I yank a word in Vim/gVim version 8.1 there is never a highlight timeout. The highlight stays indefinitely, regardless of what I set yank.highlight.duration to. Also, when I set yank.highlight.duration to less than 100 ms there is sometimes no highlight at all.

Yanking in NeoVim however times out according to yank.highlight.duration.

OS: Antergos Linux x86_64
Node version: v12.10.0
Coc.nvim version: 0.0.74-c97d41aa1e
chemzqm commented 5 years ago

No idea, could be caused by vim option or other plugin, you can disable this feature