Skip to content

Commit

Permalink
plugin/magit.vim: jump through closed file too
Browse files Browse the repository at this point in the history
ref #99
  • Loading branch information
jreybert committed Feb 23, 2017
1 parent 88ae24d commit aed8056
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ endfunction
" param[in] dir: can be 'N' (for next) or 'P' (for previous)
function! magit#jump_hunk(dir)
let back = ( a:dir == 'P' ) ? 'b' : ''
let line = search("^@@ ", back . 'wn')
let line = search('\%(^@@ \|' . g:magit_file_re . '\)', back . 'wn')
if ( line != 0 )
if ( foldlevel(line('.')) == 2 )
try
Expand All @@ -1096,6 +1096,15 @@ function! magit#jump_hunk(dir)
endtry
endif
call cursor(line, 0)

if ( foldlevel(line('.')) == 0 )
return
endif
" if current line if an header file of an open file, go next
if ( foldlevel(line('.')) == 1 )
let line = search('\%(^@@ \|' . g:magit_file_re . '\)', back . 'wn')
call cursor(line, 0)
endif
while ( foldclosed(line) != -1 )
try
foldopen
Expand Down

0 comments on commit aed8056

Please sign in to comment.