asyncomplete-file.vim
asyncomplete-file.vim copied to clipboard
Vim freezes when editing around URL-like text
When I edited a markdown file, I experienced vim freezing several times. It seems that fnamemodify() is the reason.
https://github.com/prabirshrestha/asyncomplete-file.vim/blob/99707aad551d0863268323febacd038aa66074ad/autoload/asyncomplete/sources/file.vim#L33
If l:cwd is a text like '//a/b/c', vim freezes several seconds. Probably, fnamemodify() might try to search for a network drive in windows os (?) If l:cwd starts with \\ current one is expected behavior, but it would be nice to avoid it if l:cwd starts with //.
I'm using gvim 8.1.1005 on windows 10.
How to reproduce
- Prepare a buffer contains a URL-like text
https://foo.com/
- Vim freezes when insert a character after
foo.com/and a space.
https://foo.com/ a
This problem would occur only the first time.
Does it reproduce in v2 branch?
Yes, I'm using v2 branch.
Another example I've found that seems to cause a massive freeze - is typing out a block comment in css or js: /** and when typing that final / it just locks up.
Confirm on vim/gvim (8.1.158), neovim-nightly.
- latest async, asyncomplete, asyncomplete-file
- OS: win10

To reproduce:
- paste
git clone https://github.com/habamax/vim-asciidoctor.git ./habamax/start/vim-asciidoctor
git clone https://github.com/habamax/vim-evalvim.git ./habamax/start/vim-evalvim
git clone https://github.com/habamax/vim-skipit.git ./habamax/start/vim-skipit
git clone https://github.com/habamax/vim-elixir-mix-test.git ./habamax/start/vim-elixir-mix-test
git clone https://github.com/habamax/vim-sendtoterm.git ./habamax/start/vim-sendtoterm
git clone https://github.com/habamax/vim-colors-defminus.git ./habamax/start/vim-colors-defminus
git clone https://github.com/habamax/vim-colors-defnoche.git ./habamax/start/vim-colors-defnoche
git clone https://github.com/habamax/vim-colors-lessthan.git ./habamax/start/vim-colors-lessthan
git clone https://github.com/habamax/vim-winlayout.git ./habamax/start/vim-winlayout
git clone https://github.com/habamax/vim-num2words.git ./habamax/start/vim-num2words
- goto
winlayoutword cwand type anything
It also hangs even with the following string:
/$ typing every character after this symbols causing small freeze
got the same issue, and I think it's the globpath()'s issue: file.vim#L50
when a:ctx['typed'] is http://, the l:kw and l:cwd would be //, finally causing a globpath call with this:
globpath('//', '.\=[^.]*')
a workaround:
let l:kw = matchstr(l:typed, '<\@<!\(\.\{0,2}/\|\~\).*$')
" add these lines:
if match(l:kw, '^//') >= 0
let l:kw = strpart(l:kw, 1)
endif
@ZSaberLv0 does it also support ** pattern as in https://github.com/prabirshrestha/asyncomplete-file.vim/issues/14? related PR: https://github.com/prabirshrestha/asyncomplete-file.vim/pull/11
I think it's different issue
#14 result to globpath('/**', '.\=[^.]*') , I think it would recursively glob the entire file system, with tons of result, which caused slow
this issue resut to globpath('//', '.\=[^.]*'), which would try to glob network drives, and it's very slow for Windows, even with limited result, but only for the first time
maybe, the best solution would be:
let l:kw = substitute(l:kw, '\(/\|^\)\*\+\(/\|$\)', '\1\2', 'g')
let l:kw = substitute(l:kw, '\\', '/', 'g')
let l:kw = substitute(l:kw, '//\+', '/', 'g')