comparison plugin/lawrencium.vim @ 24:21a879a09f20

Trying to keep the cursor line when open an already opened file in `Hgstatus`.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 20 Dec 2011 15:25:51 -0800
parents 84bceffbb19c
children 0e952b7c79d7
comparison
equal deleted inserted replaced
23:84bceffbb19c 24:21a879a09f20
388 endfunction 388 endfunction
389 389
390 function! s:HgStatus_FileEdit() abort 390 function! s:HgStatus_FileEdit() abort
391 " Get the path of the file the cursor is on. 391 " Get the path of the file the cursor is on.
392 let l:filename = s:HgStatus_GetSelectedPath() 392 let l:filename = s:HgStatus_GetSelectedPath()
393 393
394 " Go back to the previous window and open the file there, or open an 394 " If the file is already open in a window, jump to that window.
395 " existing buffer. 395 " Otherwise, jump to the previous window and open it there.
396 for nr in range(1, winnr('$'))
397 let l:br = winbufnr(nr)
398 let l:bpath = fnamemodify(bufname(l:br), ':p')
399 if l:bpath ==# l:filename
400 execute nr . 'wincmd w'
401 return
402 endif
403 endfor
396 wincmd p 404 wincmd p
397 if bufexists(l:filename) 405 execute 'edit ' . l:filename
398 execute 'buffer ' . l:filename
399 else
400 execute 'edit ' . l:filename
401 endif
402 endfunction 406 endfunction
403 407
404 function! s:HgStatus_FileAdd() abort 408 function! s:HgStatus_FileAdd() abort
405 " Get the path of the file the cursor is on, and its status. 409 " Get the path of the file the cursor is on, and its status.
406 let l:filename = s:HgStatus_GetSelectedPath() 410 let l:filename = s:HgStatus_GetSelectedPath()