From aed8056023f4d055b6281f84b11ecdf323e91166 Mon Sep 17 00:00:00 2001
From: Jerome Reybert <jreybert@gmail.com>
Date: Thu, 23 Feb 2017 22:51:46 +0100
Subject: [PATCH] plugin/magit.vim: jump through closed file too

ref #99
---
 plugin/magit.vim | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/plugin/magit.vim b/plugin/magit.vim
index fcbd011..d08a83c 100644
--- a/plugin/magit.vim
+++ b/plugin/magit.vim
@@ -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
@@ -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
-- 
GitLab