From: Sami Salonen Date: Thu, 7 Mar 2019 03:34:17 +0000 (+0200) Subject: Put cursor in last line if old position is invalid (#641) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/1580477615c3d14b029fc40904a10dfd31cc99a6?ds=inline Put cursor in last line if old position is invalid (#641) --- diff --git a/plugin/black.vim b/plugin/black.vim index 34f30c5..f0b55b2 100644 --- a/plugin/black.vim +++ b/plugin/black.vim @@ -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():