Add GitGutterFold command.

Closes #286, #571.
This commit is contained in:
Andy Stewart
2019-01-14 11:48:24 +00:00
parent 8d7a71ddd6
commit ac787afa02
5 changed files with 93 additions and 0 deletions

View File

@@ -123,6 +123,30 @@ function! gitgutter#hunk#cursor_in_hunk(hunk) abort
return 0
endfunction
function! gitgutter#hunk#in_hunk(lnum)
" Hunks are sorted in the order they appear in the buffer.
for hunk in gitgutter#hunk#hunks(bufnr(''))
" if in a hunk on first line of buffer
if a:lnum == 1 && hunk[2] == 0
return 1
endif
" if in a hunk generally
if a:lnum >= hunk[2] && a:lnum < hunk[2] + (hunk[3] == 0 ? 1 : hunk[3])
return 1
endif
" if hunk starts after the given line
if a:lnum < hunk[2]
return 0
endif
endfor
return 0
endfunction
function! gitgutter#hunk#text_object(inner) abort
let hunk = s:current_hunk()