davidhalter / jedi-vim

Using the jedi autocompletion library for VIM.
MIT License
5.28k stars 370 forks source link

call signature breaks undo #651

Closed Kareeeeem closed 3 years ago

Kareeeeem commented 7 years ago

Issue

When the call_signature option is on it breaks undo. let g:jedi#show_call_signatures=0 solves it.

Steps to reproduce

Initial state of buffer

x = [1, 2, 3, 4]

blah = 5

for i in range(len(x)): if i == 2: break

blah = 5

* undo with `u`. 

The buffer now looks like this

x = [1, 2, 3, 4] if i == 2: break

blah = 5


The `for` statement is removed but anything after that line remains. No matter how many times I undo.

### Versions

 - jedi-vim: 0.10.0
 - Vim / Neovim: VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec 15 2016 03:33:53) Included patches: 1-134
 - Python: 3.5.2

### Output of the "JediDebugInfo" command (in a Python buffer)
Using Python version: 3
 - sys.version: 3.5.2+ (default, Dec 13 2016, 14:16:35), [GCC 6.2.1 20161124]
 - site module: /usr/lib/python3.5/site.py
Jedi path: /home/kareem/.vim/plugged/jedi-vim/jedi/jedi/__init__.py
Jedi version: 0.10.0
jedi-vim git version: 80378d8
jedi git submodule status:  2ba78ab725f1e02dfef8bc50b0204cf656e8ee23 jedi (v0.9.0-547
-g2ba78ab7)

### Output of the "messages" Vim command

Messages maintainer: Bram Moolenaar Bram@vim.org "git-tags" 43L, 1103C 3 fewer lines; before #29 13 seconds ago

### Output of "scriptnames" Vim command

1: /usr/share/vim/vimrc 2: /usr/share/vim/vim80/debian.vim 3: ~/.vimrc 4: /usr/share/vim/vim80/filetype.vim 5: /usr/share/vim/vim80/ftplugin.vim 6: /usr/share/vim/vim80/indent.vim 7: /usr/share/vim/vim80/syntax/syntax.vim 8: /usr/share/vim/vim80/syntax/synload.vim 9: /usr/share/vim/vim80/syntax/syncolor.vim 10: ~/.vim/autoload/plug.vim 11: /usr/share/vim/vim80/ftoff.vim 12: ~/.vim/plugged/vim-javascript/ftdetect/javascript.vim 13: ~/.vim/plugged/nofrils/colors/nofrils-dark.vim 14: /usr/share/vim/vim80/scripts.vim 15: ~/.vim/plugged/vim-commentary/plugin/commentary.vim 16: ~/.vim/plugged/vim-surround/plugin/surround.vim 17: ~/.vim/plugged/neomake/plugin/neomake.vim 18: ~/.fzf/plugin/fzf.vim 19: ~/.vim/plugged/fzf.vim/plugin/fzf.vim 20: ~/.vim/plugged/editorconfig-vim/plugin/editorconfig.vim 21: /usr/share/vim/vim80/plugin/getscriptPlugin.vim 22: /usr/share/vim/vim80/plugin/gzip.vim 23: /usr/share/vim/vim80/plugin/logiPat.vim 24: /usr/share/vim/vim80/plugin/manpager.vim 25: /usr/share/vim/vim80/plugin/matchparen.vim 26: /usr/share/vim/vim80/plugin/netrwPlugin.vim 27: /usr/share/vim/vim80/plugin/rrhelper.vim 28: /usr/share/vim/vim80/plugin/spellfile.vim 29: /usr/share/vim/vim80/plugin/tarPlugin.vim 30: /usr/share/vim/vim80/plugin/tohtml.vim 31: /usr/share/vim/vim80/plugin/vimballPlugin.vim 32: /usr/share/vim/vim80/plugin/zipPlugin.vim 33: /usr/share/vim/vim80/ftplugin/python.vim 34: /usr/share/vim/vim80/indent/python.vim 35: ~/.vim/plugged/python-docstring-comments/syntax/python.vim 36: /usr/share/vim/vim80/syntax/python.vim 37: ~/.vim/plugged/jedi-vim/plugin/jedi.vim 38: ~/.vim/plugged/jedi-vim/after/syntax/python.vim 39: ~/.vim/plugged/jedi-vim/autoload/jedi.vim 40: ~/.vim/plugged/jedi-vim/ftplugin/python/jedi.vim 41: ~/.vim/plugged/jedi-vim/after/ftplugin/python/jedi.vim 42: ~/.vim/plugged/vim-python-pep8-indent/indent/python.vim 43: ~/.vim/plugged/neomake/autoload/neomake/highlights.vim 44: ~/.vim/plugged/neomake/autoload/neomake/utils.vim 45: ~/.vim/plugged/neomake/autoload/neomake/signs.vim 46: ~/.vim/plugged/neomake/autoload/neomake.vim 47: ~/.vim/plugged/neomake/autoload/neomake/statusline.vim

blueyed commented 7 years ago

and allow the call signature popup to appear

Where? For range and len, or just in general somewhere?

blueyed commented 7 years ago

An easier test case / related issue appears to be that with the following file, A and Esc after the call signatures appear (i.e. going into insert mode, but not changing anythng), will consider the buffer to be changed/modified:

print(

I'll look into this shortly.

blueyed commented 7 years ago

@Kareeeeem Please test #652. See https://help.github.com/articles/checking-out-pull-requests-locally/ for help on checking it out locally.

Kareeeeem commented 7 years ago

re: first comment. Any call signature popup.

I'll test out #652 and get back to you.

Kareeeeem commented 7 years ago

I'm afraid I'm still encountering the same behavior using the latest commit on your pull request

I simply did

for i in range(x):
    break

allowing the signature popup to show and then undo (multiple times) and was left with the following. It only disappears when I undo all the way to an empty file (undoing much older changes before finally removing the break statement).

    break
Using Python version: 3                                                              
 - sys.version: 3.5.2+ (default, Dec 13 2016, 14:16:35), [GCC 6.2.1 20161124]
 - site module: /usr/lib/python3.5/site.py
Jedi path: /home/kareem/.vim/plugged/jedi-vim/jedi/jedi/__init__.py
Jedi version: 0.10.0
jedi-vim git version: 2e3bdd3
jedi git submodule status:  2ba78ab725f1e02dfef8bc50b0204cf656e8ee23 jedi (v0.9.0-547
-g2ba78ab7)
blueyed commented 7 years ago

Weird. Can you try a minimal vimrc like the following?

set nocp
let &rtp .= ','.expand("$PWD").','.expand("$PWD").'/after'

let g:jedi#show_call_signatures=1

syn on
blueyed commented 7 years ago

I've seen the popup for range( in your example, but undo is OK for me, after exiting insert mode after the break.

Kareeeeem commented 7 years ago

Odd that it can't be reproduced. I have tried again with the minimal vimrc.

set nocp

call plug#begin('~/.vim/plugged')
Plug 'davidhalter/jedi-vim', {'for': 'python'}
call plug#end()

let g:jedi#show_call_signatures=1

syn on

the initial file

def blah():
    print "hello"

if __name__ == '__main__':
    blah()

insert the following allowing the popup to show

def blah():
    print "hello"

for i in range(5):
    break

if __name__ == '__main__':
    blah()

undo will never remove break. It did before (eventually) as I have persistent undo but not with this minimal vimrc.

this is the jedi debug info

Using Python version: 3

davidhalter commented 3 years ago

Same issue as #493. We are trying to get rid of changing the buffer for this feature and are trying to use floating windows.