vim-lsc icon indicating copy to clipboard operation
vim-lsc copied to clipboard

exiting insert mode is slow

Open nkanaev opened this issue 5 years ago • 7 comments

there's a small, but annoying thing that started happening after installing the plugin: when i type text fast and hit esc immediately, cursor starts "dancing" - vim switches back and forth between insert and normal modes.

i've recorded the current behaviour and the possible fix here

however, the issue still persists if i press i or a and esc afterwards immediately. i'd appreciate any help and suggestions regarding that.

nkanaev avatar Jan 29 '19 22:01 nkanaev

here's the diff of my changes. i'm not sure whether it's the best solution, since i'm not aware of the side effects it might have introduced.

slow-down-buddy.txt

thanks in advance

nkanaev avatar Jan 29 '19 22:01 nkanaev

The TextChangedI is pretty important to me, if we only send updates on TextChanged and InsertLeave then diagnostics can't be updated as you type.

I don't think I've seen this behavior, and I can't think of a reason why this plugin would cause you to go back into insert mode.

Perhaps there is some negative interaction with another plugin? Have you tried removing some others? Are you using YCM or Ale or any autocomplete plugins?

natebosch avatar Feb 07 '19 21:02 natebosch

vim-lsc was the only plugin for autocomplete that' i'd been using. i've tried switching to vim-lsp, and it doesn't seem to have that issue, probably because it doesn't bind to TextChangedI (though it binds to InsertLeave, which didn't cause the issue in vim-lsp too, as it did with my changes, so the cause might be different)

this was my vimrc when the issue started appearing.

nkanaev avatar Feb 08 '19 09:02 nkanaev

I'm not sure if it's the original issue reported here, but I am seeing some bad behavior where the cursor may move right then back left after exiting insert mode quickly following a text change.

I have been trying to track down the root cause here, but it's pretty strange. It seems like I can avoid the issue if I make the debounce timer for text changes much longer.

https://github.com/natebosch/vim-lsc/blob/71f4a6936a8c17097549fdbb61905d486b47487a/autoload/lsc/file.vim#L113

If I set that to 2000 instead of 500 I'm not able to repro the bad behavior I'm seeing, but it introduces an unacceptable lag for updating diagnostics when making an edit from normal mode. I thought maybe it had something to do with whether the timer fires before leaving insert mode, but that turned out to be a dead end. I can see the cursor movement for certain values of that timer where the mode changes before the timer fires.

natebosch avatar May 25 '20 02:05 natebosch

If I drop the use of timers altogether this doesn't seem to be a problem.

When using autocomplete we do end up flushing changes super frequently anyway, and with the recent optimization for finding diffs in large files it might not be a problem to flush on every single change... I may try that for a bit locally to see if any problems bubble up.

natebosch avatar May 25 '20 03:05 natebosch

I think in some cases the complete removal of timers causes things to feel a bit janky, but I'm not sure why and I'm not sure if I was imagining it.

A very long delay seemed to resolve it for insert mode, even with the frequent flushing for autocomplete, but it didn't feel great when making small edits from normal mode.

I might try a combination - long debounce delay for insert mode, and short for any other mode.

natebosch avatar Jun 13 '20 02:06 natebosch

Nate,

Which editor, Vim or Neovim?

I am a Neovim user myself, I don’t think I have seen this issue. I may try some Vim experiments and see how it goes.

I setup my vimrc to work with Neovim and Vim, proves handy at times like this.

bluz71 avatar Jun 20 '20 00:06 bluz71