diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 861fa51..287729d 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -3481,7 +3481,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort endif let i += 1 endwhile - let options = {'git': s:UserCommandList(), 'git_dir': s:GitDir(dir), 'flags': flags} + let options = {'git': s:UserCommandList(), 'git_dir': s:GitDir(dir), 'flags': flags, 'curwin': curwin} if empty(args) && pager is# -1 let cmd = s:StatusCommand(a:line1, a:line2, a:range, curwin ? 0 : a:line2, a:bang, a:mods, '', '', [], options) return (empty(cmd) ? 'exe' : cmd) . after @@ -6610,7 +6610,16 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort if s:HasOpt(flags, '--reverse') let temp_state.blame_reverse_end = matchstr(get(commits, 0, ''), '\.\.\zs.*') endif - if (a:line1 == 0 || a:range == 1) && a:count > 0 + if a:count == 0 && a:range == 2 + if get(a:options, 'curwin') + let edit = 'edit' + elseif a:bang + let edit = 'pedit' + else + let edit = 'split' + endif + return s:BlameCommit(s:Mods(a:mods) . edit, get(readfile(temp), 0, ''), temp_state) + elseif (a:line1 == 0 || a:range == 1) && a:count > 0 let edit = s:Mods(a:mods) . get(['edit', 'split', 'pedit', 'vsplit', 'tabedit'], a:count - (a:line1 ? a:line1 : 1), 'split') return s:BlameCommit(edit, get(readfile(temp), 0, ''), temp_state) else @@ -7264,13 +7273,20 @@ endfunction function! fugitive#MapJumps(...) abort if !&modifiable if get(b:, 'fugitive_type', '') ==# 'blob' - let blame_map = 'Git blame=v:count ? " --reverse" : ""' - call s:Map('n', '<2-LeftMouse>', ':0,1' . blame_map, '') - call s:Map('n', '', ':0,1' . blame_map, '') - call s:Map('n', 'o', ':0,2' . blame_map, '') - 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, '') + let blame_tail = '=v:count ? " --reverse" : ""' + exe s:Map('n', '<2-LeftMouse>', ':0,1Git blame' . blame_tail, '') + exe s:Map('n', '', ':0,1Git blame' . blame_tail, '') + if has('patch-8.0.1089') + exe s:Map('n', 'o', ':0,0Git blame' . blame_tail, '') + exe s:Map('n', 'p', ':0,0Git blame!' . blame_tail, '') + exe s:Map('n', 'gO', ':vertical 0,0Git blame' . blame_tail, '') + exe s:Map('n', 'O', ':tab 0,0Git blame' . blame_tail, '') + else + exe s:Map('n', 'o', ':0,2Git blame' . blame_tail, '') + exe s:Map('n', 'p', ':0,3Git blame' . blame_tail, '') + exe s:Map('n', 'gO', ':0,4Git blame' . blame_tail, '') + exe s:Map('n', 'O', ':0,5Git blame' . blame_tail, '') + endif call s:Map('n', 'D', ":echoerr 'fugitive: D has been removed in favor of dd'", '') call s:Map('n', 'dd', ":call fugitive#DiffClose()Gdiffsplit!", '') diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index de3a206..d578a75 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -470,7 +470,7 @@ function! s:ProjectionistDetect() abort endif endfunction -let s:addr_other = has('patch-8.1.560') ? '-addr=other' : '' +let s:addr_other = has('patch-8.1.560') || has('nvim-0.4.0') ? '-addr=other' : '' let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : '' let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : ''