Skip to content

Commit

Permalink
Put cursor in last line if old position is invalid (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
suola authored and JelleZijlstra committed Mar 7, 2019
1 parent 21ab37a commit 1580477
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugin/black.vim
Expand Up @@ -114,7 +114,10 @@ def Black():
else:
cursor = vim.current.window.cursor
vim.current.buffer[:] = new_buffer_str.split('\n')[:-1]
vim.current.window.cursor = cursor
try:
vim.current.window.cursor = cursor
except vim.error:
vim.current.window.cursor = (len(vim.current.buffer), 0)
print(f'Reformatted in {time.time() - start:.4f}s.')

def BlackUpgrade():
Expand Down

0 comments on commit 1580477

Please sign in to comment.