Skip to content

Commit a4ec618

Browse files
committed
fixup! fixup! Add support for call signatures in normal mode
1 parent 2c3e75a commit a4ec618

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

jedi_vim.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,7 @@ def completions():
169169
# Clear call signatures in the buffer so they aren't seen by the completer.
170170
# Call signatures in the command line can stay.
171171
if int(vim_eval("g:jedi#show_call_signatures")) == 1:
172-
restore_signatures = False
173-
for linenr, line in vim_eval('get(b:, "_jedi_callsig_orig", {})').items():
174-
# Check that the line would be reset, helps with keeping a single
175-
# undochain.
176-
if line != vim.current.buffer[int(linenr)-1]:
177-
vim_command('silent! undojoin')
178-
vim.current.buffer[int(linenr)-1] = line
179-
restore_signatures = True
172+
restore_signatures = clear_call_signatures(True)
180173

181174
base = vim.eval('a:base')
182175
source = ''
@@ -213,9 +206,7 @@ def completions():
213206
completions = []
214207

215208
if restore_signatures:
216-
cursor = vim.current.window.cursor
217-
vim_command('undo')
218-
vim.current.window.cursor = cursor
209+
show_call_signatures()
219210
vim.command('return ' + strout)
220211

221212

@@ -334,22 +325,30 @@ def show_documentation():
334325

335326

336327
@catch_and_print_exceptions
337-
def clear_call_signatures():
328+
def clear_call_signatures(temporary=False):
338329
# Check if using command line call signatures
339330
if int(vim_eval("g:jedi#show_call_signatures")) == 2:
340331
vim_command('echo ""')
341332
return
342-
cursor = vim.current.window.cursor
343333

344-
if not int(vim_eval("exists('b:_jedi_callsig_orig')")):
345-
return
346-
for linenr, line in vim_eval('b:_jedi_callsig_orig').items():
347-
# Check that the line would be reset, helps with keeping a single
348-
# undochain.
349-
if line != vim.current.buffer[int(linenr)-1]:
350-
vim_command('silent! undojoin')
351-
vim.current.buffer[int(linenr)-1] = line
352-
vim_command('unlet b:_jedi_callsig_orig')
334+
r = False
335+
orig_lines = vim_eval("get(b:, '_jedi_callsig_orig', {})")
336+
if orig_lines:
337+
orig_modified = int(vim_eval("&modified"))
338+
339+
for linenr, line in orig_lines.items():
340+
# Check that the line would be reset, helps with keeping a single
341+
# undochain.
342+
# assert line != vim.current.buffer[int(linenr)-1]
343+
if line != vim.current.buffer[int(linenr)-1]:
344+
vim.current.buffer[int(linenr)-1] = line
345+
vim_command('let b:_jedi_changing_text = changenr()')
346+
r = True
347+
if not orig_modified:
348+
vim_command('set nomodified')
349+
if not temporary:
350+
vim_command('unlet b:_jedi_callsig_orig')
351+
return r
353352

354353

355354
@_check_jedi_availability(show_error=False)
@@ -427,12 +426,15 @@ def show_call_signatures(signatures=()):
427426
if not set_lines:
428427
return
429428

429+
orig_modified = int(vim_eval("&modified"))
430430
orig_lines = {}
431431
for linenr, line in set_lines:
432432
orig_lines[linenr] = vim.current.buffer[linenr-1]
433433
vim_command('silent! undojoin')
434434
vim.current.buffer[int(linenr)-1] = line
435435
vim_command("let b:_jedi_callsig_orig = {!r}".format(orig_lines))
436+
if not orig_modified:
437+
vim_command('set nomodified')
436438

437439

438440
@catch_and_print_exceptions

0 commit comments

Comments
 (0)