show_call_signatures shows now all call signatures if there are multiple, and not just one.

This commit is contained in:
David Halter
2013-08-22 17:18:25 +04:30
parent 59be959a3d
commit 0b8448804d

View File

@@ -98,8 +98,7 @@ def completions():
completions = []
signatures = []
#print 'end', strout
show_call_signatures(signatures, len(completions))
show_call_signatures(signatures)
vim.command('return ' + strout)
@@ -200,36 +199,39 @@ def clear_call_signatures():
def show_call_signatures(signatures=()):
if vim.eval("has('conceal') && g:jedi#show_call_signatures") == '0':
return
try:
if signatures == None:
sig = get_script().call_signatures()
call_def = sig[0] if sig else None
if signatures == ():
signatures = get_script().call_signatures()
clear_call_signatures()
if call_def is None:
if not signatures:
return
row, column = call_def.bracket_start
if column < 1 or row == 0:
return # edge cases, just ignore
for i, signature in enumerate(signatures):
line, column = signature.bracket_start
# signatures are listed above each other
line_to_replace = line - i - 1
# because there's a space before the bracket
insert_column = column - 1
if insert_column < 0 or line_to_replace <= 0:
# Edge cases, when the call signature has no space on the screen.
break
# TODO check if completion menu is above or below
row_to_replace = row - 1
line = vim.eval("getline(%s)" % row_to_replace)
line = vim.eval("getline(%s)" % line_to_replace)
insert_column = column - 1 # because there's a space before the bracket
params = [p.get_code().replace('\n', '') for p in call_def.params]
params = [p.get_code().replace('\n', '') for p in signature.params]
try:
params[call_def.index] = '*%s*' % params[call_def.index]
params[signature.index] = '*%s*' % params[signature.index]
except (IndexError, TypeError):
pass
# This stuff is reaaaaally a hack! I cannot stress enough, that this is
# a stupid solution. But there is really no other yet. There is no
# possibility in VIM to draw on the screen, but there will be one (see
# :help todo Patch to access screen under Python. (Marko Mahni, 2010
# Jul 18))
# This stuff is reaaaaally a hack! I cannot stress enough, that
# this is a stupid solution. But there is really no other yet.
# There is no possibility in VIM to draw on the screen, but there
# will be one (see :help todo Patch to access screen under Python.
# (Marko Mahni, 2010 Jul 18))
text = " (%s) " % ', '.join(params)
text = ' ' * (insert_column - len(line)) + text
end_column = insert_column + len(text) - 2 # -2 due to bold symbols
@@ -258,7 +260,7 @@ def show_call_signatures(signatures=()):
tup = '%s, %s' % (len(add), replace)
repl = prefix + (regex % (tup, text)) + add + line[end_column:]
vim.eval('setline(%s, %s)' % (row_to_replace, repr(PythonToVimStr(repl))))
vim.eval('setline(%s, %s)' % (line_to_replace, repr(PythonToVimStr(repl))))
except Exception:
print(traceback.format_exc())