From 1fce93794761aec2e49de0fa386e482ff51a7108 Mon Sep 17 00:00:00 2001
From: Jerome Reybert <jreybert@gmail.com>
Date: Wed, 28 Oct 2015 09:39:32 +0100
Subject: [PATCH] syntax,plugin: fix end of diff display (section title may be
 non highlighed)

change end of diff regex, search for first blank line.
---
 common/magit_common.vim | 1 +
 plugin/magit.vim        | 4 +++-
 syntax/magit.vim        | 5 ++---
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/common/magit_common.vim b/common/magit_common.vim
index 47d488b..7773b0d 100644
--- a/common/magit_common.vim
+++ b/common/magit_common.vim
@@ -39,6 +39,7 @@ endfor
 let g:magit_section_re .= 'unknown section\)$'
 
 let g:magit_diff_re  = '^diff --git'
+let g:magit_end_diff_re  = '^$'
 let g:magit_stash_re = '^stash@{\d\+}:'
 let g:magit_hunk_re  = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'
 let g:magit_bin_re   = '^Binary files '
diff --git a/plugin/magit.vim b/plugin/magit.vim
index 4b5ee38..4f951cb 100644
--- a/plugin/magit.vim
+++ b/plugin/magit.vim
@@ -367,7 +367,8 @@ endfunction
 function! s:mg_select_file_block()
 	return <SID>mg_search_block(
 				\ [g:magit_file_re, 1],
-				\ [ [g:magit_file_re, -1],
+				\ [ [g:magit_end_diff_re, 0],
+				\   [g:magit_file_re, -1],
 				\   [g:magit_stash_re, -1],
 				\   [g:magit_section_re, -2],
 				\   [g:magit_bin_re, 0],
@@ -386,6 +387,7 @@ function! s:mg_select_hunk_block()
 	return <SID>mg_search_block(
 				\ [g:magit_hunk_re, 0],
 				\ [ [g:magit_hunk_re, -1],
+				\   [g:magit_end_diff_re, 0],
 				\   [g:magit_file_re, -1],
 				\   [g:magit_stash_re, -1],
 				\   [g:magit_section_re, -2],
diff --git a/syntax/magit.vim b/syntax/magit.vim
index 5d2c8c5..e33e322 100644
--- a/syntax/magit.vim
+++ b/syntax/magit.vim
@@ -30,11 +30,10 @@ execute 'syn region gitStash start=/' . g:magit_stash_re . '/ end=/\%(' .
  \ g:magit_stash_re . '\)\@=/ contains=stashEntry fold'
 
 execute 'syn region gitFile start=/' . g:magit_file_re . '/ end=/\%(' .
- \ g:magit_file_re . '\|' . g:magit_section_re '\)\@=/ contains=gitHunk,fileEntry fold'
+			\ g:magit_end_diff_re . '\)\@=/ contains=gitHunk,fileEntry fold'
 
 execute 'syn region gitHunk start=/' .
- \ g:magit_hunk_re . '/ end=/\%(' .
- \ g:magit_diff_re . '\|' . g:magit_hunk_re . '\|' . g:magit_section_re. '\|' . g:magit_stash_re . '\|' . g:magit_file_re .
+ \ g:magit_hunk_re . '/ end=/\%(' . g:magit_end_diff_re . '\|' . g:magit_hunk_re 
  \ '\)\@=/ contains=@diff fold'
 
 let b:current_syntax = "magit"
-- 
GitLab