# HG changeset patch # User Ludovic Chabant # Date 1324423551 28800 # Node ID 21a879a09f20a669fb6f41038ff3cf1aa7e76848 # Parent 84bceffbb19c40de18e73e458aea95bebb92bc36 Trying to keep the cursor line when open an already opened file in `Hgstatus`. diff -r 84bceffbb19c -r 21a879a09f20 plugin/lawrencium.vim --- a/plugin/lawrencium.vim Tue Dec 20 14:33:05 2011 -0800 +++ b/plugin/lawrencium.vim Tue Dec 20 15:25:51 2011 -0800 @@ -390,15 +390,19 @@ function! s:HgStatus_FileEdit() abort " Get the path of the file the cursor is on. let l:filename = s:HgStatus_GetSelectedPath() - - " Go back to the previous window and open the file there, or open an - " existing buffer. + + " If the file is already open in a window, jump to that window. + " Otherwise, jump to the previous window and open it there. + for nr in range(1, winnr('$')) + let l:br = winbufnr(nr) + let l:bpath = fnamemodify(bufname(l:br), ':p') + if l:bpath ==# l:filename + execute nr . 'wincmd w' + return + endif + endfor wincmd p - if bufexists(l:filename) - execute 'buffer ' . l:filename - else - execute 'edit ' . l:filename - endif + execute 'edit ' . l:filename endfunction function! s:HgStatus_FileAdd() abort