diff --git a/jedi_vim.py b/jedi_vim.py index 862ad3a..7eadcb0 100644 --- a/jedi_vim.py +++ b/jedi_vim.py @@ -507,8 +507,10 @@ def cmdline_call_signatures(signatures): @catch_and_print_exceptions def rename(): if not int(vim.eval('a:0')): + # Need to save the cursor position before insert mode + cursor = vim.current.window.cursor vim_command('augroup jedi_rename') - vim_command('autocmd InsertLeave call jedi#rename(1)') + vim_command('autocmd InsertLeave call jedi#rename({}, {})'.format(cursor[0], cursor[1])) vim_command('augroup END') vim_command("let s:jedi_replace_orig = expand('')") @@ -520,6 +522,8 @@ def rename(): # Remove autocommand. vim_command('autocmd! jedi_rename InsertLeave') + cursor = tuple(int(x) for x in vim.eval('a:000')) + # Get replacement, if there is something on the cursor. # This won't be the case when the user ends insert mode right away, # and `` would pick up the nearest word instead. @@ -528,8 +532,6 @@ def rename(): else: replace = None - cursor = vim.current.window.cursor - # Undo new word, but only if something was changed, which is not the # case when ending insert mode right away. if vim_eval('b:changedtick != s:jedi_changedtick') == '1':