From ba5915bf26ab8e0a9be364654e1a136ece00e5f4 Mon Sep 17 00:00:00 2001 From: Stevan Milic Date: Tue, 5 Feb 2019 20:28:46 +0100 Subject: [PATCH] Fix rename with folds: replace line in buffer directly (#906) Fixes #789 --- AUTHORS.txt | 1 + pythonx/jedi_vim.py | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index c845241..e87db71 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -52,5 +52,6 @@ Tomoyuki Kashiro (@kashiro) Tommy Allen (@tweekmonster) Mingliang (@Aulddays) Brian Mego (@brianmego) +Stevan Milic (@stevanmilic) @something are github user names. diff --git a/pythonx/jedi_vim.py b/pythonx/jedi_vim.py index 5ceee17..19aec31 100644 --- a/pythonx/jedi_vim.py +++ b/pythonx/jedi_vim.py @@ -713,16 +713,10 @@ def do_rename(replace, orig=None): buffers.add(vim.current.buffer.name) - # Save view. - saved_view = vim_eval('string(winsaveview())') - # Replace original word. - vim.current.window.cursor = (r.line, r.column) - vim_command('normal! c{0:d}l{1}'.format(len(orig), replace)) - - # Restore view. - vim_command('call winrestview(%s)' % saved_view) - highlight_usages([r], length=len(replace)) + r_line = vim.current.buffer[r.line - 1] + vim.current.buffer[r.line - 1] = (r_line[:r.column] + replace + + r_line[r.column + len(orig):]) # Restore previous tab and window. vim_command('tabnext {0:d}'.format(saved_tab))