Skip to content

Commit

Permalink
fixup! fixup! Add support for call signatures in normal mode
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Feb 7, 2017
1 parent 2c3e75a commit a4ec618
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions jedi_vim.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,7 @@ def completions():
# Clear call signatures in the buffer so they aren't seen by the completer.
# Call signatures in the command line can stay.
if int(vim_eval("g:jedi#show_call_signatures")) == 1:
restore_signatures = False
for linenr, line in vim_eval('get(b:, "_jedi_callsig_orig", {})').items():
# Check that the line would be reset, helps with keeping a single
# undochain.
if line != vim.current.buffer[int(linenr)-1]:
vim_command('silent! undojoin')
vim.current.buffer[int(linenr)-1] = line
restore_signatures = True
restore_signatures = clear_call_signatures(True)

base = vim.eval('a:base')
source = ''
Expand Down Expand Up @@ -213,9 +206,7 @@ def completions():
completions = []

if restore_signatures:
cursor = vim.current.window.cursor
vim_command('undo')
vim.current.window.cursor = cursor
show_call_signatures()
vim.command('return ' + strout)


Expand Down Expand Up @@ -334,22 +325,30 @@ def show_documentation():


@catch_and_print_exceptions
def clear_call_signatures():
def clear_call_signatures(temporary=False):
# Check if using command line call signatures
if int(vim_eval("g:jedi#show_call_signatures")) == 2:
vim_command('echo ""')
return
cursor = vim.current.window.cursor

if not int(vim_eval("exists('b:_jedi_callsig_orig')")):
return
for linenr, line in vim_eval('b:_jedi_callsig_orig').items():
# Check that the line would be reset, helps with keeping a single
# undochain.
if line != vim.current.buffer[int(linenr)-1]:
vim_command('silent! undojoin')
vim.current.buffer[int(linenr)-1] = line
vim_command('unlet b:_jedi_callsig_orig')
r = False
orig_lines = vim_eval("get(b:, '_jedi_callsig_orig', {})")
if orig_lines:
orig_modified = int(vim_eval("&modified"))

for linenr, line in orig_lines.items():
# Check that the line would be reset, helps with keeping a single
# undochain.
# assert line != vim.current.buffer[int(linenr)-1]
if line != vim.current.buffer[int(linenr)-1]:
vim.current.buffer[int(linenr)-1] = line
vim_command('let b:_jedi_changing_text = changenr()')
r = True
if not orig_modified:
vim_command('set nomodified')
if not temporary:
vim_command('unlet b:_jedi_callsig_orig')
return r


@_check_jedi_availability(show_error=False)
Expand Down Expand Up @@ -427,12 +426,15 @@ def show_call_signatures(signatures=()):
if not set_lines:
return

orig_modified = int(vim_eval("&modified"))
orig_lines = {}
for linenr, line in set_lines:
orig_lines[linenr] = vim.current.buffer[linenr-1]
vim_command('silent! undojoin')
vim.current.buffer[int(linenr)-1] = line
vim_command("let b:_jedi_callsig_orig = {!r}".format(orig_lines))
if not orig_modified:
vim_command('set nomodified')


@catch_and_print_exceptions
Expand Down

0 comments on commit a4ec618

Please sign in to comment.