From 154e2dbae3751224ae745fe5f2c02632a46d34fe Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 2 May 2015 18:46:50 +0200 Subject: [PATCH] rename: use original word's length for replacing Ref: https://github.com/davidhalter/jedi-vim/pull/403#discussion_r29548013 --- jedi_vim.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jedi_vim.py b/jedi_vim.py index 303080f..09f27a2 100644 --- a/jedi_vim.py +++ b/jedi_vim.py @@ -425,6 +425,7 @@ def rename(): vim_command('autocmd InsertLeave call jedi#rename(1)') vim_command('augroup END') + vim_eval("let s:jedi_replace_orig = expand('')") vim_command('normal! diw') vim_command(':startinsert') else: @@ -444,6 +445,7 @@ def rename(): if replace is None: echo_highlight('No rename possible, if no name is given.') else: + orig = vim_eval('s:jedi_replace_orig') temp_rename = goto(is_related_name=True, no_output=True) # sort the whole thing reverse (positions at the end of the line # must be first, because they move the stuff before the position). @@ -466,7 +468,7 @@ def rename(): saved_view = vim_eval('winsaveview()') vim.current.window.cursor = r.start_pos - vim_command('normal! cw%s' % replace) + vim_command('normal! c{:d}l{}'.format(len(orig), replace)) # Restore view. vim_command('call winrestview(%s)' % PythonToVimStr(saved_view))