mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-11 12:53:52 -05:00
Fix direct blame maps in short files
Patch 8.1.560 is the gift that keeps on giving. Let's work around this for now by bolting on a new behavior to the previously unused :0,0Git blame. Long term, we probably want to come up with a different interface.
This commit is contained in:
@@ -3481,7 +3481,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
|||||||
endif
|
endif
|
||||||
let i += 1
|
let i += 1
|
||||||
endwhile
|
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
|
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)
|
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
|
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')
|
if s:HasOpt(flags, '--reverse')
|
||||||
let temp_state.blame_reverse_end = matchstr(get(commits, 0, ''), '\.\.\zs.*')
|
let temp_state.blame_reverse_end = matchstr(get(commits, 0, ''), '\.\.\zs.*')
|
||||||
endif
|
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')
|
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)
|
return s:BlameCommit(edit, get(readfile(temp), 0, ''), temp_state)
|
||||||
else
|
else
|
||||||
@@ -7264,13 +7273,20 @@ endfunction
|
|||||||
function! fugitive#MapJumps(...) abort
|
function! fugitive#MapJumps(...) abort
|
||||||
if !&modifiable
|
if !&modifiable
|
||||||
if get(b:, 'fugitive_type', '') ==# 'blob'
|
if get(b:, 'fugitive_type', '') ==# 'blob'
|
||||||
let blame_map = 'Git blame<C-R>=v:count ? " --reverse" : ""<CR><CR>'
|
let blame_tail = '<C-R>=v:count ? " --reverse" : ""<CR><CR>'
|
||||||
call s:Map('n', '<2-LeftMouse>', ':<C-U>0,1' . blame_map, '<silent>')
|
exe s:Map('n', '<2-LeftMouse>', ':<C-U>0,1Git blame' . blame_tail, '<silent>')
|
||||||
call s:Map('n', '<CR>', ':<C-U>0,1' . blame_map, '<silent>')
|
exe s:Map('n', '<CR>', ':<C-U>0,1Git blame' . blame_tail, '<silent>')
|
||||||
call s:Map('n', 'o', ':<C-U>0,2' . blame_map, '<silent>')
|
if has('patch-8.0.1089')
|
||||||
call s:Map('n', 'p', ':<C-U>0,3' . blame_map, '<silent>')
|
exe s:Map('n', 'o', ':<C-U>0,0Git blame' . blame_tail, '<silent>')
|
||||||
call s:Map('n', 'gO', ':<C-U>0,4' . blame_map, '<silent>')
|
exe s:Map('n', 'p', ':<C-U>0,0Git blame!' . blame_tail, '<silent>')
|
||||||
call s:Map('n', 'O', ':<C-U>0,5' . blame_map, '<silent>')
|
exe s:Map('n', 'gO', ':<C-U>vertical 0,0Git blame' . blame_tail, '<silent>')
|
||||||
|
exe s:Map('n', 'O', ':<C-U>tab 0,0Git blame' . blame_tail, '<silent>')
|
||||||
|
else
|
||||||
|
exe s:Map('n', 'o', ':<C-U>0,2Git blame' . blame_tail, '<silent>')
|
||||||
|
exe s:Map('n', 'p', ':<C-U>0,3Git blame' . blame_tail, '<silent>')
|
||||||
|
exe s:Map('n', 'gO', ':<C-U>0,4Git blame' . blame_tail, '<silent>')
|
||||||
|
exe s:Map('n', 'O', ':<C-U>0,5Git blame' . blame_tail, '<silent>')
|
||||||
|
endif
|
||||||
|
|
||||||
call s:Map('n', 'D', ":echoerr 'fugitive: D has been removed in favor of dd'<CR>", '<silent><unique>')
|
call s:Map('n', 'D', ":echoerr 'fugitive: D has been removed in favor of dd'<CR>", '<silent><unique>')
|
||||||
call s:Map('n', 'dd', ":<C-U>call fugitive#DiffClose()<Bar>Gdiffsplit!<CR>", '<silent>')
|
call s:Map('n', 'dd', ":<C-U>call fugitive#DiffClose()<Bar>Gdiffsplit!<CR>", '<silent>')
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ function! s:ProjectionistDetect() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
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_tabs = has('patch-7.4.542') ? '-addr=tabs' : ''
|
||||||
let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : ''
|
let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : ''
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user