rename: save/restore tab/windows; not via new_buffer

Ref: https://github.com/davidhalter/jedi-vim/pull/364#discussion-diff-25785992
This commit is contained in:
Daniel Hahler
2015-05-02 16:38:47 +02:00
parent 676c558110
commit fc95545378

View File

@@ -428,10 +428,13 @@ def rename():
vim_command('normal! diw')
vim_command(':startinsert')
else:
window_path = vim.current.buffer.name
# reset autocommand
vim_command('autocmd! jedi_rename InsertLeave')
# Save original window / tab.
saved_tab = int(vim_eval('tabpagenr()'))
saved_win = int(vim_eval('winnr()'))
replace = vim_eval("expand('<cword>')")
vim_command('normal! u') # undo new word
cursor = vim.current.window.cursor
@@ -458,9 +461,10 @@ def rename():
vim.current.window.cursor = r.start_pos
vim_command('normal! cw%s' % replace)
result = new_buffer(window_path)
if not result:
return
# Restore previous tab and window.
vim_command('tabnext {:d}'.format(saved_tab))
vim_command('{:d}wincmd w'.format(saved_win))
vim.current.window.cursor = cursor
echo_highlight('Jedi did %s renames!' % len(temp_rename))