asyncomplete-file.vim icon indicating copy to clipboard operation
asyncomplete-file.vim copied to clipboard

Vim freezes when editing around URL-like text

Open machakann opened this issue 6 years ago • 9 comments

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.

machakann avatar Mar 13 '19 13:03 machakann

How to reproduce

  1. Prepare a buffer contains a URL-like text
https://foo.com/
  1. Vim freezes when insert a character after foo.com/ and a space.
https://foo.com/ a

This problem would occur only the first time.

machakann avatar Mar 13 '19 14:03 machakann

Does it reproduce in v2 branch?

prabirshrestha avatar Mar 13 '19 15:03 prabirshrestha

Yes, I'm using v2 branch.

machakann avatar Mar 13 '19 16:03 machakann

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.

amadeus avatar Aug 19 '19 20:08 amadeus

Confirm on vim/gvim (8.1.158), neovim-nightly.

  • latest async, asyncomplete, asyncomplete-file
  • OS: win10

asyncomplete-file

To reproduce:

  1. 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
  1. goto winlayout word
  2. cw and type anything

habamax avatar Jan 28 '20 11:01 habamax

It also hangs even with the following string:

/$ typing every character after this symbols causing small freeze

Shatur avatar Mar 10 '20 19:03 Shatur

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 avatar Jul 11 '22 14:07 ZSaberLv0

@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

prabirshrestha avatar Jul 11 '22 21:07 prabirshrestha

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')

ZSaberLv0 avatar Jul 12 '22 03:07 ZSaberLv0