mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-08 11:34:51 +08:00
vim: prevent renames from happening, if they are empty.
This commit is contained in:
22
jedi.vim
22
jedi.vim
@@ -112,22 +112,26 @@ if 1:
|
|||||||
vim.command('normal! diw')
|
vim.command('normal! diw')
|
||||||
vim.command(':startinsert')
|
vim.command(':startinsert')
|
||||||
else:
|
else:
|
||||||
|
# reset autocommand
|
||||||
|
vim.command('autocmd! jedi_rename InsertLeave')
|
||||||
|
|
||||||
current_buf = vim.current.buffer.name
|
current_buf = vim.current.buffer.name
|
||||||
replace = vim.eval("expand('<cword>')")
|
replace = vim.eval("expand('<cword>')")
|
||||||
vim.command('normal! u') # undo new word
|
vim.command('normal! u') # undo new word
|
||||||
vim.command('normal! u') # 2u didn't work...
|
vim.command('normal! u') # 2u didn't work...
|
||||||
|
|
||||||
for r in temp_rename:
|
if replace is None:
|
||||||
start_pos = r.start_pos + (0, 1) # vim cursor starts with 1 indent
|
echo_highlight('No rename possible, if no name is given.')
|
||||||
# TODO switch modules
|
else:
|
||||||
if vim.current.buffer.name == r.module_path:
|
for r in temp_rename:
|
||||||
vim.current.window.cursor = r.start_pos
|
start_pos = r.start_pos + (0, 1) # vim cursor starts with 1 indent
|
||||||
vim.command('normal! cw%s' % replace)
|
# TODO switch modules
|
||||||
|
if vim.current.buffer.name == r.module_path:
|
||||||
|
vim.current.window.cursor = r.start_pos
|
||||||
|
vim.command('normal! cw%s' % replace)
|
||||||
|
|
||||||
# reset autocommand
|
|
||||||
vim.command('autocmd! jedi_rename InsertLeave')
|
|
||||||
|
|
||||||
echo_highlight('Jedi did %s renames!' % len(temp_rename))
|
echo_highlight('Jedi did %s renames!' % len(temp_rename))
|
||||||
# reset rename variables
|
# reset rename variables
|
||||||
temp_rename = None
|
temp_rename = None
|
||||||
PYTHONEOF
|
PYTHONEOF
|
||||||
|
|||||||
Reference in New Issue
Block a user