mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-09 03:53:47 -05:00
Return early when pre-condition not met
This commit is contained in:
@@ -46,12 +46,14 @@ endfunction
|
|||||||
|
|
||||||
function! gitgutter#hunk#next_hunk(count) abort
|
function! gitgutter#hunk#next_hunk(count) abort
|
||||||
let bufnr = bufnr('')
|
let bufnr = bufnr('')
|
||||||
if gitgutter#utility#is_active(bufnr)
|
if !gitgutter#utility#is_active(bufnr) | return | endif
|
||||||
|
|
||||||
let hunks = gitgutter#hunk#hunks(bufnr)
|
let hunks = gitgutter#hunk#hunks(bufnr)
|
||||||
if empty(hunks)
|
if empty(hunks)
|
||||||
call gitgutter#utility#warn('No hunks in file')
|
call gitgutter#utility#warn('No hunks in file')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let current_line = line('.')
|
let current_line = line('.')
|
||||||
let hunk_count = 0
|
let hunk_count = 0
|
||||||
for hunk in hunks
|
for hunk in hunks
|
||||||
@@ -64,17 +66,18 @@ function! gitgutter#hunk#next_hunk(count) abort
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
call gitgutter#utility#warn('No more hunks')
|
call gitgutter#utility#warn('No more hunks')
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#hunk#prev_hunk(count) abort
|
function! gitgutter#hunk#prev_hunk(count) abort
|
||||||
let bufnr = bufnr('')
|
let bufnr = bufnr('')
|
||||||
if gitgutter#utility#is_active(bufnr)
|
if !gitgutter#utility#is_active(bufnr) | return | endif
|
||||||
|
|
||||||
let hunks = gitgutter#hunk#hunks(bufnr)
|
let hunks = gitgutter#hunk#hunks(bufnr)
|
||||||
if empty(hunks)
|
if empty(hunks)
|
||||||
call gitgutter#utility#warn('No hunks in file')
|
call gitgutter#utility#warn('No hunks in file')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let current_line = line('.')
|
let current_line = line('.')
|
||||||
let hunk_count = 0
|
let hunk_count = 0
|
||||||
for hunk in reverse(copy(hunks))
|
for hunk in reverse(copy(hunks))
|
||||||
@@ -88,7 +91,6 @@ function! gitgutter#hunk#prev_hunk(count) abort
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
call gitgutter#utility#warn('No previous hunks')
|
call gitgutter#utility#warn('No previous hunks')
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Returns the hunk the cursor is currently in or an empty list if the cursor
|
" Returns the hunk the cursor is currently in or an empty list if the cursor
|
||||||
|
|||||||
Reference in New Issue
Block a user