neoclide / coc-snippets

Snippets solution for coc.nvim
966 stars 41 forks source link

typing fast causes cursor to jump to wrong position #212

Closed fabOnReact closed 3 years ago

fabOnReact commented 3 years ago

The cursor jumps to the wrong position when typing fast.

The user does the following operations:

Result The user has to delete the output and repeat the operation. The user can not type fast while using snippets.

The java snippet used (reproduces also with other languages):

snippet lg [ "FLog.w(TESING..)" ]
FLog.w("TESTING::", "${1}: " + ( ${1} ));
endsnippet

Below the video showcasing the bug

CLICK TO OPEN TESTS RESULTS

| **cursor jumps in the wrong position when typing fast** | |:-------------------------:| |

chemzqm commented 3 years ago

Please provide result from :CocInfo

fabOnReact commented 3 years ago

Thanks @chemzqm

I was able to create a new test case with video and log

CLICK TO OPEN VIDEO RESULTS

| **AFTER** | |:-------------------------:| |

CLICK TO OPEN THE FULL LOG

``` vim version: NVIM v0.5.0-dev+1099-g4d5dbea4f node version: v15.8.0 coc.nvim version: 0.0.80-710549b96b coc.nvim directory: /home/fabrizio/.vim/plugged/coc.nvim term: screen-256color platform: linux ## Log of coc.nvim 2021-03-03T09:50:10.445 INFO (pid:10195) [extensions] - Skipped load vim plugin from "/home/fabrizio/.vim/plugged/vscode-es7-javascript-react-snippets", "es7-react-js-snippets" already global extension. 2021-03-03T09:50:10.816 INFO (pid:10195) [plugin] - coc.nvim 0.0.80-710549b96b initialized with node: v15.8.0 after 419ms 2021-03-03T09:51:15.076 INFO (pid:10195) [watchman] - watchman watching project: /home/fabrizio/Documents/sourcecode/opensource/react-native 2021-03-03T10:42:44.446 INFO (pid:10195) [services] - registered service "flow" 2021-03-03T10:42:45.484 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T10:42:46.544 INFO (pid:10195) [completion-complete] - Results from: snippets 2021-03-03T10:42:46.641 INFO (pid:10195) [completion-complete] - Results from: snippets 2021-03-03T10:42:47.034 INFO (pid:10195) [completion-complete] - Results from: snippets 2021-03-03T10:42:47.167 INFO (pid:10195) [completion-complete] - Results from: snippets 2021-03-03T10:42:48.012 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T10:42:49.311 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 3 ] 2021-03-03T10:58:44.010 INFO (pid:10195) [services] - Flow state change: stopped => starting 2021-03-03T10:58:44.037 INFO (pid:10195) [services] - registered service "tsserver" 2021-03-03T10:58:44.063 INFO (pid:10195) [language-client-index] - Language server "flow" started with 23372 2021-03-03T10:58:44.111 INFO (pid:10195) [services] - service tsserver started 2021-03-03T10:58:44.297 INFO (pid:10195) [services] - Flow state change: starting => running 2021-03-03T10:58:44.301 INFO (pid:10195) [services] - service flow started 2021-03-03T10:59:26.991 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 1 ] 2021-03-03T10:59:30.751 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 1 ] 2021-03-03T10:59:55.290 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 1 ] 2021-03-03T11:00:05.903 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 1 ] 2021-03-03T11:40:14.839 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 7 ] 2021-03-03T11:44:37.488 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T11:44:42.821 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T11:44:43.013 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T11:44:46.367 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T11:44:48.067 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T11:44:59.899 INFO (pid:10195) [completion-complete] - Results from: file 2021-03-03T11:45:01.904 INFO (pid:10195) [snippets-session] - Cursor insert out of range, cancelling snippet session 2021-03-03T11:45:02.270 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T11:45:04.995 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T11:45:05.066 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T11:45:08.165 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T11:45:10.119 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T11:45:10.523 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T11:45:10.895 INFO (pid:10195) [completion-complete] - Results from: around,snippets 2021-03-03T11:56:54.602 INFO (pid:10195) [attach] - receive notification: openList [ 'snippets' ] 2021-03-03T12:01:59.178 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 18 ] 2021-03-03T12:03:54.826 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 18 ] 2021-03-03T12:04:13.291 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 8 ] 2021-03-03T12:04:14.138 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T12:04:22.818 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 18 ] 2021-03-03T12:04:41.912 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 8 ] 2021-03-03T12:07:18.228 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:07:20.137 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:07:20.734 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:07:21.905 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T12:07:22.236 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:07:24.917 INFO (pid:10195) [snippets-session] - Cursor insert out of range, cancelling snippet session 2021-03-03T12:07:25.716 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:07:27.615 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:07:29.079 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:07:29.788 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:07:32.391 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 8 ] 2021-03-03T12:07:33.155 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T12:10:33.029 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:10:36.238 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:10:39.167 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 35 ] 2021-03-03T12:10:39.937 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T12:23:59.719 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:24:11.094 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 35 ] 2021-03-03T12:24:13.809 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:24:15.467 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T12:24:18.944 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 35 ] 2021-03-03T12:24:19.795 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:43:01.441 INFO (pid:10195) [completion-complete] - Results from: file 2021-03-03T15:43:02.668 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 8 ] 2021-03-03T15:43:12.482 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:43:12.528 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:43:12.822 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:05.685 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:05.910 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:45:06.084 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:12.186 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:13.949 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:15.997 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:17.111 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:23.251 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:23.771 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:45:23.973 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:26.259 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:27.922 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:28.059 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:28.232 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:33.077 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 35 ] 2021-03-03T15:45:48.528 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:45:51.214 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufWritePre', 35 ] 2021-03-03T15:46:16.309 INFO (pid:10195) [attach] - receive notification: showInfo [] 2021-03-03T15:46:16.384 INFO (pid:10195) [attach] - receive request: CocAutocmd [ 'BufReadCmd', 'output', 'output:///info' ] 2021-03-03T15:46:58.600 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:00.156 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:01.940 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:47:02.228 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:05.202 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:06.676 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:07.912 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:47:08.330 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:08.553 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:47:09.988 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:10.742 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:10.886 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:11.145 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:12.254 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:47:12.599 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:13.212 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:13.248 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:47:15.572 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:47:15.932 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:31.762 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:32.650 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:32.882 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:47:33.053 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:34.059 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:47:42.099 INFO (pid:10195) [attach] - receive notification: showInfo [] 2021-03-03T15:53:56.192 INFO (pid:10195) [snippets-session] - Cursor insert out of range, cancelling snippet session 2021-03-03T15:53:56.570 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:53:57.380 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:53:58.940 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:00.223 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:01.716 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:54:13.671 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:14.827 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:15.944 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:17.668 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:54:18.556 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:19.661 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:20.648 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:21.287 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:54:22.665 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:54:23.195 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:24.984 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:26.718 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:28.092 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:54:28.779 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:30.210 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:31.992 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:54:32.603 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:34.498 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:34.648 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:54:34.914 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:35.150 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:35.349 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:36.088 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:36.399 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:54:38.916 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:54:39.414 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:40.948 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:41.538 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:41.553 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:54:41.763 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:41.947 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:42.204 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:43.001 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:54:43.489 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:44.637 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:44.834 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:45.090 INFO (pid:10195) [snippets-session] - Change outside placeholder, cancelling snippet session 2021-03-03T15:54:45.121 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:45.138 INFO (pid:10195) [attach] - receive notification: stopCompletion [] 2021-03-03T15:54:45.389 INFO (pid:10195) [completion-complete] - Results from: around,buffer,snippets 2021-03-03T15:54:57.643 INFO (pid:10195) [attach] - receive notification: showInfo [] ```

chemzqm commented 3 years ago

I've tried, but can't reproduce, consider try minimal vimrc.

fabOnReact commented 3 years ago

@chemzqm no problem. currently I'm contributing on other projects. I would keep the issue open so that me or other opensource mantainers may see this issue and try to solve it. I will try during my weekends to reproduce it with minimal vimrc, but right now I need to work on other projects. Thanks a lot

fabOnReact commented 3 years ago

I still experience this, when typing i and then quickly another character. As in the screenrecording above, it is caused by : command, probably there is some conflict with vim shortcuts as before typing we don't go in insert mode

chemzqm commented 3 years ago

@fabriziobertoglio1987 Still not able to reproduce, it was improved with coc.nvim before, try upgrade your coc.nvim.

fabOnReact commented 3 years ago

@chemzqm I was able to fix this on Ubuntu by using https://github.com/fabriziobertoglio1987/dotfiles-ubuntu/blob/master/snippets_js

snippet coob [ "log an object" ]
console.log("${1}", ${1});
endsnippet

but the problem still persists on my MacBook Pro and it is very irritating I did the following which did not fix: 1) Upgrade coc 2) comment all plugins and vim lines

situation improved considerably.. but the problem seems not to be configs itself, but how slow is CoC-Snippets.. somehow running all this plugins together, CocSnippets seems to not handle well when you type too fast

so I think only solution is not using this plugin https://github.com/ycm-core/YouCompleteMe#general-usage

I can not invest any more time trying to configure this

chemzqm commented 3 years ago

@fabriziobertoglio1987 Unable to reproduce on my mac, try minimal vimrc.

jfab20 commented 3 years ago

I got the exact same problem, I don't know if it solves your problem but try disabling the relativenumber option (causes a lot of lag, especially in large files.

chemzqm commented 3 years ago

Reproduced on big file.

chemzqm commented 3 years ago

Fixed on latest release branch of coc.nvim.

fabOnReact commented 3 years ago

seems I'll have to go back using coc, as flow is not compatible with youcompleteme https://github.com/facebook/flow/issues/7986

fabOnReact commented 3 years ago

@chemzqm please re-open this. I can also reproduce with relative numbers. Now my solution is trying to use YouCompleteMe and coc-flow at the same time.

CLICK TO OPEN TESTS RESULTS

https://user-images.githubusercontent.com/24992535/132087791-d968aa06-339c-47df-8b39-41f329450a89.mp4 ![image](https://user-images.githubusercontent.com/24992535/132087838-f8c67f24-a78b-4945-b664-2abe7f0db1a7.png)

chemzqm commented 3 years ago

Can't reproduce, please provide :CocInfo and debug log https://github.com/neoclide/coc.nvim/wiki/Debug-coc.nvim#inspect-communication-between-vim-and-cocnvim

fabOnReact commented 3 years ago

t release branch

at least include the commit you used to fix this. I'll have a look, but I'm thinking of using default vim functionality for snippets instead of coc

chemzqm commented 3 years ago

Seems you typed " which move your cursor outside placeholder, the snippet session is cancelled.

fabOnReact commented 3 years ago
let b:coc_suggest_disable = 1

thanks, I never had this type of with YouCompleteMe in fact I will try installing youcompleteme aside to coc and you YouCompleteMe for the autocomplete, while Coc for coc-flow (navigating file references)

chemzqm commented 3 years ago

It's up to you, we just need debug log of coc.nvim to understand what happened :h :CocOpenLog

chemzqm commented 3 years ago

Seems you have coc-paris installed and when you type ", your cursor jump out the placeholder, and what happended is expected.

fabOnReact commented 3 years ago

I don't think, because I'm all the time in insert mode and that command should not run while in insert mode. I did not type <C-]> or esc to exit insert mode so I don't see how can such command trigger.

Plug 'tpope/vim-surround'
Plug 'alvan/vim-closetag'

I don't have this type of problems with ycm, infact I disabled autocompletion in coc

{
  "suggest.autoTrigger": "none",
}

I only use coc-flow for navigating flow projects

but for the rest I will use ycm

thanks

fabOnReact commented 3 years ago

@chemzqm you are right. typing " will cause this issue. Thanks. Sorry for being so stubborn. Hopefully I'll get the chance to contribute to COC.