forked from VimPlug/jedi-vim
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:
12
jedi_vim.py
12
jedi_vim.py
@@ -428,10 +428,13 @@ def rename():
|
|||||||
vim_command('normal! diw')
|
vim_command('normal! diw')
|
||||||
vim_command(':startinsert')
|
vim_command(':startinsert')
|
||||||
else:
|
else:
|
||||||
window_path = vim.current.buffer.name
|
|
||||||
# reset autocommand
|
# reset autocommand
|
||||||
vim_command('autocmd! jedi_rename InsertLeave')
|
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>')")
|
replace = vim_eval("expand('<cword>')")
|
||||||
vim_command('normal! u') # undo new word
|
vim_command('normal! u') # undo new word
|
||||||
cursor = vim.current.window.cursor
|
cursor = vim.current.window.cursor
|
||||||
@@ -458,9 +461,10 @@ def rename():
|
|||||||
vim.current.window.cursor = r.start_pos
|
vim.current.window.cursor = r.start_pos
|
||||||
vim_command('normal! cw%s' % replace)
|
vim_command('normal! cw%s' % replace)
|
||||||
|
|
||||||
result = new_buffer(window_path)
|
# Restore previous tab and window.
|
||||||
if not result:
|
vim_command('tabnext {:d}'.format(saved_tab))
|
||||||
return
|
vim_command('{:d}wincmd w'.format(saved_win))
|
||||||
|
|
||||||
vim.current.window.cursor = cursor
|
vim.current.window.cursor = cursor
|
||||||
echo_highlight('Jedi did %s renames!' % len(temp_rename))
|
echo_highlight('Jedi did %s renames!' % len(temp_rename))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user