neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.47k stars 954 forks source link

当搜索出大量unlist buffer时, 界面卡顿 #2683

Closed SolaWing closed 3 years ago

SolaWing commented 3 years ago

Result from CocInfo

versions

vim version: NVIM v0.4.4 node version: v15.3.0 coc.nvim version: 0.0.79-5a9a0f22a2 coc.nvim directory: /Users/wang/MAC/.vim/bundle/coc.nvim term: Apple_Terminal platform: darwin

Log of coc.nvim

2020-12-07T18:19:38.086 INFO (pid:81498) [services] - registered service "languageserver.sourcekit-lsp" 2020-12-07T18:19:38.286 INFO (pid:81498) [services] - registered service "solargraph" 2020-12-07T18:19:38.320 INFO (pid:81498) [plugin] - coc.nvim 0.0.79-5a9a0f22a2 initialized with node: v15.3.0 after 309ms 2020-12-07T18:19:43.185 INFO (pid:81498) [completion-complete] - Results from: ultisnips,solargraph-1,tag,around,tabnine 2020-12-07T18:19:46.150 INFO (pid:81498) [completion-complete] - Results from: around,solargraph-1,tabnine,tag,ultisnips 2020-12-07T18:20:09.336 INFO (pid:81498) [completion-complete] - Results from: solargraph-1,around,tabnine,tag 2020-12-07T18:20:11.714 INFO (pid:81498) [completion-complete] - Results from: around,solargraph-1,tabnine,tag,ultisnips 2020-12-07T18:20:12.980 INFO (pid:81498) [completion-complete] - Results from: solargraph-1 2020-12-07T18:20:17.449 INFO (pid:81498) [completion-complete] - Results from: solargraph-1,ultisnips 2020-12-07T18:20:20.024 INFO (pid:81498) [completion-complete] - Results from: solargraph-1,around,tabnine,tag 2020-12-07T18:20:23.676 INFO (pid:81498) [completion-complete] - Results from: solargraph-1,around,tabnine,tag,ultisnips 2020-12-07T18:20:27.196 INFO (pid:81498) [completion-complete] - Results from: around,solargraph-1,tabnine,tag,ultisnips 2020-12-07T18:20:33.016 INFO (pid:81498) [completion-complete] - Results from: solargraph-1,around,tabnine,tag,ultisnips 2020-12-07T18:20:46.775 INFO (pid:81498) [completion-complete] - Results from: around,solargraph-1,tabnine,tag 2020-12-07T18:20:50.121 INFO (pid:81498) [completion-complete] - Results from: solargraph-1,around,tabnine,tag 2020-12-07T18:20:52.269 INFO (pid:81498) [completion-complete] - Results from: around,tabnine,tag 2020-12-07T18:20:54.127 INFO (pid:81498) [completion-complete] - Results from: around,tag 2020-12-07T18:20:55.602 INFO (pid:81498) [completion-complete] - Results from: solargraph-1,tabnine,tag 2020-12-07T18:20:55.696 INFO (pid:81498) [completion-complete] - Results from: solargraph-1 2020-12-07T18:21:00.695 INFO (pid:81498) [completion-complete] - Results from: solargraph-1,around,tabnine,tag,ultisnips 2020-12-07T18:21:04.927 INFO (pid:81498) [completion-complete] - Results from: solargraph-1,around,tabnine,tag,ultisnips 2020-12-07T18:21:09.485 INFO (pid:81498) [completion-complete] - Results from: around,tabnine 2020-12-07T18:21:10.212 INFO (pid:81498) [completion-complete] - Results from: solargraph-1 2020-12-07T18:21:12.124 INFO (pid:81498) [completion-complete] - Results from: solargraph-1,tabnine,tag,ultisnips 2020-12-07T18:21:13.385 INFO (pid:81498) [completion-complete] - Results from: tabnine,solargraph-1,tag

Describe the bug

当搜索出大量unlist buffer时,输入会有卡顿。 期望unlisted和隐藏的buffer不会导致卡顿

Reproduce the bug

#!/usr/bin/env ruby

contents = "# a very long line, a very long line, a very long line, a very long line, a very long line, a very long line\n"
contents = contents * 9999;
contents << "keyword"
5000.times do |i|
  File.write("#{i}.rb", contents)
end

用上面脚本创建大量文件,然后搜索keyword使得buffer被加载到unlisted buffer里。(ls!会显示,但是ls不会)。之后的输入就会有明显的卡顿感。使用:%bwipe命令清空所有buffer后恢复不再卡顿。(%bdelete没有效果)

chemzqm commented 3 years ago

如何搜索?

chemzqm commented 3 years ago

应该是你自己 vim 或者机器的问题

SolaWing commented 3 years ago

如何搜索?

我使用的mhinz/vim-grepper 进行的搜索。我试试用最原始的vim看能不能复现

SolaWing commented 3 years ago

@chemzqm 我创建了一个最小化的vim demo,并装上solargraph插件(其他languageserver应该也能复现)。在创建buffer并在vim通过LoadBuffer加载qlist后,在rb文件insert mode狂打字,可以很明显的看到卡顿。

source ~/.vim/vim-plug/plug.vim “ 替换为vim-plug插件vim的目录
set nocompatible
call plug#begin('~/.vim/bundle')

Plug 'neoclide/coc.nvim', {'branch': 'release'}

" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup

" Give more space for displaying messages.
set cmdheight=2

" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=2000

" Don't pass messages to |ins-completion-menu|.
set shortmess+=c

" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes

inoremap <silent><expr> <TAB>
      \ pumvisible() ? "\<C-n>" :
      \ <SID>check_back_space() ? "\<TAB>" :
      \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"

function! s:check_back_space() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()

" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
if has('patch8.1.1068')
  " Use `complete_info` if your (Neo)Vim version supports it.
  inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
  imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif

call plug#end()

function! LoadBuffer() range
let alist = []
let lnum = 0
while lnum < 5000
    call add(alist, {"filename": printf("%d.rb", lnum), "lnum": 1})
    let lnum += 1
endw
call setqflist(alist)
endfunction