From 2735e3ab59ba37cce0f1bea29fbd04302f0e4663 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Thu, 12 Apr 2018 08:36:21 +0200 Subject: [PATCH] Make file_at_revision() preserve cursor position note that this may still change the cursor position due to deletions and insertions further up in the file, but now the cursor should at least end up somewhere near its original position for smaller commits. --- vimrc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vimrc b/vimrc index 5817606..517f35f 100644 --- a/vimrc +++ b/vimrc @@ -400,6 +400,7 @@ function! s:git_prev() endfun function! s:file_at_revision(rev) + let l:pos = getpos(".") if exists("b:git_original_file") " Is this already a file@revision buffer? let l:fname = b:git_original_file let l:ftail = fnamemodify(b:git_original_file, ":t") @@ -418,6 +419,9 @@ function! s:file_at_revision(rev) let b:git_original_file = l:fname let b:git_revision_hash = a:rev + let l:pos[0] = bufnr('.') + call setpos('.', l:pos) + redraw call s:git_info() endfun