]> git.draconx.ca Git - vimconf.git/commitdiff
Tighten constraints on line when restoring last file position.
authorNick Bowler <nbowler@elliptictech.com>
Fri, 3 Feb 2012 14:10:33 +0000 (09:10 -0500)
committerNick Bowler <nbowler@elliptictech.com>
Fri, 3 Feb 2012 14:10:33 +0000 (09:10 -0500)
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

index f53735fb270dd9e9561627e60706438c496fdda8..48fe1422c47a58766b232e8eef421ba88b134f8e 100644 (file)
@@ -17,6 +17,6 @@ let g:leave_my_cursor_position_alone=1
 
 " Jump to last cursor position when editing a file.
 autocmd BufReadPost *
 
 " 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
        \       execute "goto" line2byte(line("'\"")) |
        \ endif