Add :SignifyPreviewHunk
This is merely a first draft that needs to get refined further.
This commit is contained in:
parent
83b226f069
commit
b7ea1a1bb2
@ -61,6 +61,42 @@ function! sy#repo#job_exit_show_signs(bufnr, vcs, exitval, diff) abort
|
|||||||
call setbufvar(a:bufnr, 'sy_job_id_'.a:vcs, 0)
|
call setbufvar(a:bufnr, 'sy_job_id_'.a:vcs, 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function: #job_exit_preview_hunk {{{1
|
||||||
|
function! sy#repo#job_exit_preview_hunk(_bufnr, _vcs, _exitval, diff) abort
|
||||||
|
let in_hunk = 0
|
||||||
|
let hunk = []
|
||||||
|
|
||||||
|
for line in a:diff
|
||||||
|
if in_hunk
|
||||||
|
if line[:2] == '@@ '
|
||||||
|
silent! wincmd P
|
||||||
|
if !&previewwindow
|
||||||
|
noautocmd botright new
|
||||||
|
endif
|
||||||
|
call setline(1, hunk)
|
||||||
|
silent! %foldopen!
|
||||||
|
setlocal previewwindow filetype=diff buftype=nofile bufhidden=delete
|
||||||
|
noautocmd wincmd p
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
call add(hunk, line)
|
||||||
|
elseif line[:2] == '@@ ' && s:is_line_in_hunk(line)
|
||||||
|
let in_hunk = 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:is_line_in_hunk(hunkline)
|
||||||
|
let curline = line('.')
|
||||||
|
let [old_line, new_line, old_count, new_count] = sy#sign#parse_hunk(a:hunkline)
|
||||||
|
|
||||||
|
if curline >= new_line && curline <= (new_line + new_count)
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
return 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Function: sy#get_diff_start {{{1
|
" Function: sy#get_diff_start {{{1
|
||||||
function! sy#repo#get_diff_start(vcs, func) abort
|
function! sy#repo#get_diff_start(vcs, func) abort
|
||||||
call sy#verbose('sy#repoget_diff_start()', a:vcs)
|
call sy#verbose('sy#repoget_diff_start()', a:vcs)
|
||||||
@ -303,6 +339,13 @@ function! sy#repo#diffmode(do_tab) abort
|
|||||||
normal! ]czt
|
normal! ]czt
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function: #preview_hunk {{{1
|
||||||
|
function! sy#repo#preview_hunk() abort
|
||||||
|
if exists('b:sy') && has_key(b:sy, 'updated_by')
|
||||||
|
call sy#repo#get_diff_start(b:sy.updated_by, function('sy#repo#job_exit_preview_hunk'))
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Function: s:initialize_job {{{1
|
" Function: s:initialize_job {{{1
|
||||||
function! s:initialize_job(vcs) abort
|
function! s:initialize_job(vcs) abort
|
||||||
let vcs_cmd = s:expand_cmd(a:vcs, g:signify_vcs_cmds)
|
let vcs_cmd = s:expand_cmd(a:vcs, g:signify_vcs_cmds)
|
||||||
|
@ -67,6 +67,7 @@ command! -nargs=0 -bar SignifyList call sy#debug#list_active_bu
|
|||||||
command! -nargs=0 -bar SignifyDebug call sy#repo#debug_detection()
|
command! -nargs=0 -bar SignifyDebug call sy#repo#debug_detection()
|
||||||
command! -nargs=0 -bar -bang SignifyFold call sy#fold#dispatch(<bang>1)
|
command! -nargs=0 -bar -bang SignifyFold call sy#fold#dispatch(<bang>1)
|
||||||
command! -nargs=0 -bar -bang SignifyDiff call sy#repo#diffmode(<bang>1)
|
command! -nargs=0 -bar -bang SignifyDiff call sy#repo#diffmode(<bang>1)
|
||||||
|
command! -nargs=0 -bar SignifyPreviewHunk call sy#repo#preview_hunk()
|
||||||
command! -nargs=0 -bar SignifyRefresh call sy#util#refresh_windows()
|
command! -nargs=0 -bar SignifyRefresh call sy#util#refresh_windows()
|
||||||
command! -nargs=0 -bar SignifyEnable call sy#enable()
|
command! -nargs=0 -bar SignifyEnable call sy#enable()
|
||||||
command! -nargs=0 -bar SignifyDisable call sy#disable()
|
command! -nargs=0 -bar SignifyDisable call sy#disable()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user