2013-09-30 04:19:31 -04:00
|
|
|
" vim: et sw=2 sts=2
|
|
|
|
|
2013-08-19 11:36:16 -04:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
2013-07-17 06:30:58 -04:00
|
|
|
" Function: #next_hunk {{{1
|
|
|
|
function! sy#jump#next_hunk(count)
|
2013-11-21 20:57:43 -05:00
|
|
|
if !exists('b:sy')
|
2013-07-17 06:30:58 -04:00
|
|
|
echomsg 'signify: I cannot detect any changes!'
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
let lnum = line('.')
|
2013-11-21 20:57:43 -05:00
|
|
|
let hunks = filter(copy(b:sy.hunks), 'v:val.start > lnum')
|
2013-07-21 01:20:32 -04:00
|
|
|
let hunk = get(hunks, a:count - 1, get(hunks, -1, {}))
|
2013-07-17 06:30:58 -04:00
|
|
|
|
|
|
|
if !empty(hunk)
|
2013-11-21 20:57:43 -05:00
|
|
|
execute 'sign jump '. hunk.ids[0] .' buffer='. b:sy.buffer
|
2013-07-17 06:30:58 -04:00
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Function: #prev_hunk {{{1
|
|
|
|
function! sy#jump#prev_hunk(count)
|
2013-11-21 20:57:43 -05:00
|
|
|
if !exists('b:sy')
|
2013-07-17 06:30:58 -04:00
|
|
|
echomsg 'signify: I cannot detect any changes!'
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
let lnum = line('.')
|
2013-11-21 20:57:43 -05:00
|
|
|
let hunks = filter(copy(b:sy.hunks), 'v:val.start < lnum')
|
2013-07-21 01:20:32 -04:00
|
|
|
let hunk = get(hunks, 0 - a:count, get(hunks, 0, {}))
|
2013-07-17 06:30:58 -04:00
|
|
|
|
|
|
|
if !empty(hunk)
|
2013-11-21 20:57:43 -05:00
|
|
|
execute 'sign jump '. hunk.ids[0] .' buffer='. b:sy.buffer
|
2013-07-17 06:30:58 -04:00
|
|
|
endif
|
|
|
|
endfunction
|