Vim freezes when typing a comment on the first line of the file. Here "freezes" means that it becomes impossible to exit insert mode nor can anything be inserted. This only happens when entering a comment on the first line of the edited Python file. This isn't about ctrl-s :)
To perform the tests I created a clean environment as follows:
Contents of .vimrc
call plug#begin('~/.vim/plugged')
Plug 'davidhalter/jedi-vim'
call plug#end()
The following tests were performed and all of them begin by opening the empty test file test.py and entering insert mode:
Using Python version: 3
omnifunc=
completeopt=menuone,longest,preview
Last set from ~/.vim/plugged/jedi-vim/plugin/jedi.vim
No output other than "Messages maintainer: Bram Moolenaar Bram@vim.org".
1: /usr/share/vim/vimrc
2: /usr/share/vim/vim74/debian.vim
3: /usr/share/vim/vim74/syntax/syntax.vim
4: /usr/share/vim/vim74/syntax/synload.vim
5: /usr/share/vim/vim74/syntax/syncolor.vim
6: /usr/share/vim/vim74/filetype.vim
7: ~/.vimrc
8: ~/.vim/autoload/plug.vim
9: /usr/share/vim/vim74/ftoff.vim
10: /usr/share/vim/vim74/ftplugin.vim
11: /usr/share/vim/vim74/indent.vim
12: ~/.vim/plugged/jedi-vim/plugin/jedi.vim
13: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
14: /usr/share/vim/vim74/plugin/gzip.vim
15: /usr/share/vim/vim74/plugin/logiPat.vim
16: /usr/share/vim/vim74/plugin/matchparen.vim
17: /usr/share/vim/vim74/plugin/netrwPlugin.vim
18: /usr/share/vim/vim74/plugin/rrhelper.vim
19: /usr/share/vim/vim74/plugin/spellfile.vim
20: /usr/share/vim/vim74/plugin/tarPlugin.vim
21: /usr/share/vim/vim74/plugin/tohtml.vim
22: /usr/share/vim/vim74/plugin/vimballPlugin.vim
23: /usr/share/vim/vim74/plugin/zipPlugin.vim
24: ~/.vim/plugged/jedi-vim/autoload/jedi.vim
My VIM freezes after Ctrl+Space after dot. I see 100% load of CPU with process of VIM.
Ubuntu 14.04 i386
@vitaly-zdanevich no abnormal CPU usage seen in this case.
I'm experiencing a similar issue, but only with specific packages like scipy, numpy, matplotlib, etc.
It takes about 10seconds to load.
It does not freeze, however, for math, os, sys, etc.
I'm using neovim 0.1.7, jedi-vim 0.10.0, on a macOS Sierra.
The following is Jedi-vim debug information.
Using Python version: 2
g:force_py_version = '2' (default: 'auto')
g:completions_command = '<C-N>' (default: '<C-Space>')
omnifunc=jedi#completions
Last set from ~/.vim/plugged/jedi-vim/after/ftplugin/python/jedi.vim
completeopt=menuone,longest,preview
Last set from ~/.vim/plugged/jedi-vim/plugin/jedi.vim
I'm experiencing a similar issue, but only with specific packages like scipy, numpy, matplotlib, etc.
@Zeta611 this issue occurs with an empty file. What do you mean by specific packages? When editing empty files within those packages? When having imported modules from those packages? Or are you referring to @vitaly-zdanevich's 100% CPU issue? To me it appears that that has nothing to do with this issue and it might be warranted to create another one because this one has ostensibly nothing to do with autocompletion.
Confirmed in Vim, but not Neovim.
It is triggered caused by g:jedi#show_call_signatures
(both 1 and 2, using 0 does not trigger it).
set nocompatible
let script_dir = fnamemodify(expand('<sfile>'), ':h')
let &runtimepath .= ','.script_dir.','.script_dir.'/after'
let g:jedi#auto_vim_configuration = 1
" let g:jedi#show_call_signatures=1
syntax on
filetype plugin indent on
TEST CASE:
1. echo -n '#dead' > t-dead.py
2. vim -u minimal.vimrc '+norm $' '+startinsert' t-dead.py
3. Press `Esc`, then `A`.
(It also happens in Neovim, but call signatures are a bit buggy there))
git-bisected to https://github.com/davidhalter/jedi/commit/8f4b86289249bc6b10ec8982d73777ebc1b169fb in Jedi.
It seems like there is an endless loop via get_script().call_signatures()
used by jedi-vim.
/cc @davidhalter
I cannot reproduce it with Jedi directly though
% python -c "print(__import__('jedi').Script('#dead', 1, 5, '/home/user/.dotfiles/vim/plugged/jedi-vim/t-dead.py', 'utf-8').call_signatures())"
[]
It needs to be called twice:
% python -c "print(__import__('jedi').Script('#dead', 1, 5, '…/vim/plugged/jedi-vim/t-dead.py', 'utf-8').call_signatures()); print(__import__('jedi').Script('#dead', 1, 5, '…/vim/plugged/jedi-vim/t-dead.py', 'utf-8').call_signatures());"
[]
^CTraceback (most recent call last):
File "…/vim/plugged/jedi-vim/jedi/jedi/cache.py", line 87, in wrapper
return dct[key]
KeyError: ((), frozenset())
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "…/vim/plugged/jedi-vim/jedi/jedi/parser/tree.py", line 311, in get_start_pos_of_prefix
return self.get_previous_leaf().end_pos
File "…/vim/plugged/jedi-vim/jedi/jedi/parser/tree.py", line 256, in get_previous_leaf
raise IndexError('Cannot access the previous element of the first one.')
IndexError: Cannot access the previous element of the first one.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "…/vim/plugged/jedi-vim/jedi/jedi/api/__init__.py", line 300, in call_signatures
helpers.get_call_signature_details(self._get_module_node(), self._pos)
File "…/vim/plugged/jedi-vim/jedi/jedi/cache.py", line 89, in wrapper
result = method(self, *args, **kwargs)
File "…/vim/plugged/jedi-vim/jedi/jedi/api/__init__.py", line 137, in _get_module_node
parser = FastParser(self._grammar, self._source, self.path)
File "…/vim/plugged/jedi-vim/jedi/jedi/parser/diff.py", line 33, in __call__
parser.module = parser._parsed = d.update(new_lines)
File "…/vim/plugged/jedi-vim/jedi/jedi/parser/diff.py", line 178, in update
self._parse(until_line=j2)
File "…/vim/plugged/jedi-vim/jedi/jedi/parser/diff.py", line 292, in _parse
nodes[0].get_start_pos_of_prefix()[0],
File "…/vim/plugged/jedi-vim/jedi/jedi/parser/tree.py", line 313, in get_start_pos_of_prefix
return self.line - self.prefix.count('\n'), 0 # It's the first leaf.
KeyboardInterrupt
Reported for jedi in https://github.com/davidhalter/jedi/issues/878.
@blueyed that was fast. Very nice.
Thanks a lot for debugging @blueyed !
@denarced No, I'm not experiencing CPU 100% issue.
What I meant by "specific packages":
When I edit a file and import a module from a package using from a import b
, e.g. from matplotlib import pyplot
, (neo)vim freezes for about ten seconds when I type space after matplotlib
.
It also freezes when I type .
(dot) after matplotlib
.
However, the lag takes only about .5 seconds or so for packages like sys, os, math
, etc.
Happens here also --- hard freeze after entering the "#" comment after the she-bang line.
Fortunately you can write the fist two lines with any other editor and then go using jedi... ;-)
@Rmano I noticed the issue with shebang. I have since added it with echo :)
lol. The work arounds :-D
@davidhalter
We should have a bugfix release with a fix for this severe issue, and possibly others.
I could try preparing something by cherry-picking, but maybe you want to do it instead?
I'm on it. Didn't really have time/motivation to look at the issues. I have had 10 issues open that I want to quickly look at. I have already fixed 3. I hope to be able to push it this week.
Should be fixed by now.
Most helpful comment
I'm on it. Didn't really have time/motivation to look at the issues. I have had 10 issues open that I want to quickly look at. I have already fixed 3. I hope to be able to push it this week.