From bcb0f14b9d398d7282b0f3941a045c535a42e8a6 Mon Sep 17 00:00:00 2001 From: David Halter Date: Tue, 11 Sep 2012 01:08:09 +0200 Subject: [PATCH] vim: prevent renames from happening, if they are empty. --- jedi.vim | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/jedi.vim b/jedi.vim index 720cdc4..6ac95fa 100644 --- a/jedi.vim +++ b/jedi.vim @@ -112,22 +112,26 @@ if 1: vim.command('normal! diw') vim.command(':startinsert') else: + # reset autocommand + vim.command('autocmd! jedi_rename InsertLeave') + current_buf = vim.current.buffer.name replace = vim.eval("expand('')") vim.command('normal! u') # undo new word vim.command('normal! u') # 2u didn't work... - for r in temp_rename: - start_pos = r.start_pos + (0, 1) # vim cursor starts with 1 indent - # TODO switch modules - if vim.current.buffer.name == r.module_path: - vim.current.window.cursor = r.start_pos - vim.command('normal! cw%s' % replace) + if replace is None: + echo_highlight('No rename possible, if no name is given.') + else: + for r in temp_rename: + start_pos = r.start_pos + (0, 1) # vim cursor starts with 1 indent + # 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 temp_rename = None PYTHONEOF