# HG changeset patch # User Shane Harper # Date 1578713387 -39600 # Sat Jan 11 14:29:47 2020 +1100 # Node ID fb65725f28720805f31f23f8852427e72e4823e1 # Parent 06f4d2c01fd6daa712f9f1eb70f4e4b39a82df44 Use winsaveview() and winrestview() to save a few lines of code. diff --git a/autoload/lawrencium/annotate.vim b/autoload/lawrencium/annotate.vim --- a/autoload/lawrencium/annotate.vim +++ b/autoload/lawrencium/annotate.vim @@ -43,9 +43,8 @@ setlocal nowrap nofoldenable setlocal filetype=hgannotate else - " Store some info about the current buffer. - let l:cur_topline = line('w0') + &scrolloff - let l:cur_line = line('.') + " Store some info about the current window. + let l:view = winsaveview() let l:cur_wrap = &wrap let l:cur_foldenable = &foldenable @@ -70,11 +69,7 @@ call l:annotate_buffer.OnDelete('setlocal foldenable') endif - " Go to the line we were at in the source buffer when we - " opened the annotation window. - execute l:cur_topline - normal! zt - execute l:cur_line + call winrestview({'lnum': l:view.lnum, 'topline': l:view.topline}) syncbind " Set the correct window width for the annotations.