parent
ad113a64fc
commit
6902f6bc1c
1 changed files with 16 additions and 3 deletions
|
@ -1043,16 +1043,29 @@ endfunction
|
|||
" ------------------------------------------------------------------
|
||||
" Commits / BCommits
|
||||
" ------------------------------------------------------------------
|
||||
function! s:yank_to_register(data)
|
||||
let @" = a:data
|
||||
silent! let @* = a:data
|
||||
silent! let @+ = a:data
|
||||
endfunction
|
||||
|
||||
function! s:commits_sink(lines)
|
||||
if len(a:lines) < 2
|
||||
return
|
||||
endif
|
||||
|
||||
let pat = '[0-9a-f]\{7,9}'
|
||||
|
||||
if a:lines[0] == 'ctrl-y'
|
||||
let hashes = join(filter(map(a:lines[1:], 'matchstr(v:val, pat)'), 'len(v:val)'))
|
||||
return s:yank_to_register(hashes)
|
||||
end
|
||||
|
||||
let diff = a:lines[0] == 'ctrl-d'
|
||||
let cmd = s:action_for(a:lines[0], 'e')
|
||||
let buf = bufnr('')
|
||||
for idx in range(1, len(a:lines) - 1)
|
||||
let sha = matchstr(a:lines[idx], '[0-9a-f]\{7,9}')
|
||||
let sha = matchstr(a:lines[idx], pat)
|
||||
if !empty(sha)
|
||||
if diff
|
||||
if idx > 1
|
||||
|
@ -1098,8 +1111,8 @@ function! s:commits(buffer_local, args)
|
|||
\ 'sink*': s:function('s:commits_sink'),
|
||||
\ 'options': ['--ansi', '--multi', '--tiebreak=index', '--reverse',
|
||||
\ '--inline-info', '--prompt', command.'> ', '--bind=ctrl-s:toggle-sort',
|
||||
\ '--header', ':: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort',
|
||||
\ '--expect='.expect_keys]
|
||||
\ '--header', ':: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort, '.s:magenta('CTRL-Y', 'Special').' to yank commit hashes',
|
||||
\ '--expect=ctrl-y,'.expect_keys]
|
||||
\ }
|
||||
|
||||
if a:buffer_local
|
||||
|
|
Loading…
Add table
Reference in a new issue