Skip to content

Commit

Permalink
Fix rename with folds: replace line in buffer directly (#906)
Browse files Browse the repository at this point in the history
Fixes #789
  • Loading branch information
stevanmilic authored and blueyed committed Feb 5, 2019
1 parent c5c13d6 commit ba5915b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ Tomoyuki Kashiro (@kashiro)
Tommy Allen (@tweekmonster)
Mingliang (@Aulddays)
Brian Mego (@brianmego)
Stevan Milic (@stevanmilic) <stevan.milic@yahoo.com>

@something are github user names.
12 changes: 3 additions & 9 deletions pythonx/jedi_vim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit ba5915b

Please sign in to comment.