Refactoring
This commit is contained in:
parent
a804002c21
commit
3d3edac39d
@ -42,10 +42,7 @@ endfunction
|
|||||||
|
|
||||||
" Function: #enable {{{1
|
" Function: #enable {{{1
|
||||||
function! sy#fold#enable(do_tab) abort
|
function! sy#fold#enable(do_tab) abort
|
||||||
if !exists('b:sy')
|
execute sy#util#return_if_no_changes()
|
||||||
echomsg 'signify: I cannot detect any changes!'
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:do_tab
|
if a:do_tab
|
||||||
tabedit %
|
tabedit %
|
||||||
|
@ -4,10 +4,7 @@ scriptencoding utf-8
|
|||||||
|
|
||||||
" Function: #next_hunk {{{1
|
" Function: #next_hunk {{{1
|
||||||
function! sy#jump#next_hunk(count)
|
function! sy#jump#next_hunk(count)
|
||||||
if !exists('b:sy')
|
execute sy#util#return_if_no_changes()
|
||||||
echomsg 'signify: I cannot detect any changes!'
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let hunks = filter(copy(b:sy.hunks), 'v:val.start > lnum')
|
let hunks = filter(copy(b:sy.hunks), 'v:val.start > lnum')
|
||||||
@ -20,10 +17,7 @@ endfunction
|
|||||||
|
|
||||||
" Function: #prev_hunk {{{1
|
" Function: #prev_hunk {{{1
|
||||||
function! sy#jump#prev_hunk(count)
|
function! sy#jump#prev_hunk(count)
|
||||||
if !exists('b:sy')
|
execute sy#util#return_if_no_changes()
|
||||||
echomsg 'signify: I cannot detect any changes!'
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let hunks = filter(copy(b:sy.hunks), 'v:val.start < lnum')
|
let hunks = filter(copy(b:sy.hunks), 'v:val.start < lnum')
|
||||||
|
@ -210,11 +210,7 @@ endfunction
|
|||||||
|
|
||||||
" Function: #get_stats {{{1
|
" Function: #get_stats {{{1
|
||||||
function! sy#repo#get_stats() abort
|
function! sy#repo#get_stats() abort
|
||||||
if !exists('b:sy') || !has_key(b:sy, 'stats')
|
return exists('b:sy') ? b:sy.stats : [-1, -1, -1]
|
||||||
return [-1, -1, -1]
|
|
||||||
endif
|
|
||||||
|
|
||||||
return b:sy.stats
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: #debug_detection {{{1
|
" Function: #debug_detection {{{1
|
||||||
@ -245,10 +241,8 @@ endfunction
|
|||||||
|
|
||||||
" Function: #diffmode {{{1
|
" Function: #diffmode {{{1
|
||||||
function! sy#repo#diffmode() abort
|
function! sy#repo#diffmode() abort
|
||||||
if !exists('b:sy')
|
execute sy#util#return_if_no_changes()
|
||||||
echomsg 'signify: I cannot detect any changes!'
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let vcs = b:sy.updated_by
|
let vcs = b:sy.updated_by
|
||||||
if !has_key(g:signify_vcs_cmds_diffmode, vcs)
|
if !has_key(g:signify_vcs_cmds_diffmode, vcs)
|
||||||
echomsg 'SignifyDiff has no support for: '. vcs
|
echomsg 'SignifyDiff has no support for: '. vcs
|
||||||
|
@ -43,14 +43,13 @@ endfunction
|
|||||||
|
|
||||||
" Function: #hunk_text_object {{{1
|
" Function: #hunk_text_object {{{1
|
||||||
function! sy#util#hunk_text_object(emptylines) abort
|
function! sy#util#hunk_text_object(emptylines) abort
|
||||||
if !exists('b:sy')
|
execute sy#util#return_if_no_changes()
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let lnum = line('.')
|
let lnum = line('.')
|
||||||
let hunks = filter(copy(b:sy.hunks), 'v:val.start <= lnum && v:val.end >= lnum')
|
let hunks = filter(copy(b:sy.hunks), 'v:val.start <= lnum && v:val.end >= lnum')
|
||||||
|
|
||||||
if empty(hunks)
|
if empty(hunks)
|
||||||
|
echomsg 'signify: Here is no hunk.'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -89,3 +88,12 @@ function! sy#util#chdir() abort
|
|||||||
\ : (exists(':tcd') && haslocaldir(-1, 0)) ? 'tcd' : 'cd'
|
\ : (exists(':tcd') && haslocaldir(-1, 0)) ? 'tcd' : 'cd'
|
||||||
return [getcwd(), chdir]
|
return [getcwd(), chdir]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function: #has_changes {{{1
|
||||||
|
function! sy#util#return_if_no_changes() abort
|
||||||
|
if !exists('b:sy') || empty(b:sy.hunks)
|
||||||
|
echomsg 'signify: There are no changes.'
|
||||||
|
return 'return'
|
||||||
|
endif
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user