From 0b203a2db3676d26ab822c52353bc739baff3f75 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Fri, 3 Feb 2012 09:10:33 -0500 Subject: [PATCH] Tighten constraints on line when restoring last file position. Otherwise, line2byte(1) will returns -1 when opening an empty file, and an error will be produced when trying to jump to that non-existent position. Just require the previous line to be >1 before trying to use it, since changing position to line 1 is pointless anyway. --- plugin/keymap.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/keymap.vim b/plugin/keymap.vim index f53735f..48fe142 100644 --- a/plugin/keymap.vim +++ b/plugin/keymap.vim @@ -17,6 +17,6 @@ let g:leave_my_cursor_position_alone=1 " Jump to last cursor position when editing a file. autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ if line("'\"") > 1 && line("'\"") <= line("$") | \ execute "goto" line2byte(line("'\"")) | \ endif -- 2.43.0