From 6a04e875f8aca3f56f0753618f2dd7aad61fb9ff Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 14 Aug 2019 10:57:40 -0400 Subject: [PATCH] Provide diff maps in blobs --- autoload/fugitive.vim | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index c14c579..44bb8f6 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -3901,6 +3901,20 @@ function! s:OpenParse(args) abort return [s:Expand(file), join(pre)] endfunction +function! s:DiffClose() abort + let mywinnr = winnr() + for winnr in [winnr('#')] + range(winnr('$'),1,-1) + if winnr != mywinnr && getwinvar(winnr,'&diff') + execute winnr.'wincmd w' + close + if winnr('$') > 1 + wincmd p + endif + endif + endfor + diffoff! +endfunction + function! s:BlurStatus() abort if (&previewwindow || exists('w:fugitive_status')) && get(b:,'fugitive_type', '') ==# 'index' let winnrs = filter([winnr('#')] + range(1, winnr('$')), 's:UsableWin(v:val)') @@ -3910,17 +3924,7 @@ function! s:BlurStatus() abort belowright new endif if &diff - let mywinnr = winnr() - for winnr in range(winnr('$'),1,-1) - if winnr != mywinnr && getwinvar(winnr,'&diff') - execute winnr.'wincmd w' - close - if winnr('$') > 1 - wincmd p - endif - endif - endfor - diffoff! + call s:DiffClose() endif endif endfunction @@ -5366,6 +5370,15 @@ function! fugitive#MapJumps(...) abort call s:Map('n', 'p', ':0,3' . blame_map, '') call s:Map('n', 'gO', ':0,4' . blame_map, '') call s:Map('n', 'O', ':0,5' . blame_map, '') + + call s:Map('n', 'D', ":call DiffClose()Gdiffsplit!redrawechohl WarningMsg echo ':Gstatus D is deprecated in favor of dd'echohl NONE", '') + call s:Map('n', 'dd', ":call DiffClose()Gdiffsplit!", '') + call s:Map('n', 'dh', ":call DiffClose()Ghdiffsplit!", '') + call s:Map('n', 'ds', ":call DiffClose()Ghdiffsplit!", '') + call s:Map('n', 'dv', ":call DiffClose()Gvdiffsplit!", '') + call s:Map('n', 'dp', ":Git diff !^..! -- %", '') + call s:Map('n', 'd?', ":help fugitive_d", '') + else call s:Map('n', '', ':exe GF("edit")', '') call s:Map('n', 'o', ':exe GF("split")', '')