fix 's:path undefined' errors

Closes #14.
This commit is contained in:
Marco Hinz 2013-03-26 23:09:13 +01:00
parent 5383932dca
commit c6dfab4a9e

View File

@ -112,11 +112,11 @@ augroup signify
autocmd! autocmd!
if exists('g:signify_cursorhold_normal') && (g:signify_cursorhold_normal == 1) if exists('g:signify_cursorhold_normal') && (g:signify_cursorhold_normal == 1)
autocmd CursorHold * write | call s:start(s:file) autocmd CursorHold * write | call s:start(s:path)
endif endif
if exists('g:signify_cursorhold_insert') && (g:signify_cursorhold_insert == 1) if exists('g:signify_cursorhold_insert') && (g:signify_cursorhold_insert == 1)
autocmd CursorHoldI * write | call s:start(s:file) autocmd CursorHoldI * write | call s:start(s:path)
endif endif
if !has('gui_win32') if !has('gui_win32')
@ -124,8 +124,8 @@ augroup signify
endif endif
autocmd VimEnter,ColorScheme * call s:colors_set() autocmd VimEnter,ColorScheme * call s:colors_set()
autocmd BufEnter * let s:file = resolve(expand('<afile>:p')) autocmd BufEnter * let s:path = resolve(expand('<afile>:p'))
autocmd BufEnter,BufWritePost * call s:start(s:file) autocmd BufEnter,BufWritePost * call s:start(s:path)
augroup END augroup END
com! -nargs=0 -bar SignifyToggle call s:toggle_signify() com! -nargs=0 -bar SignifyToggle call s:toggle_signify()
@ -185,7 +185,6 @@ function! s:start(path) abort
sign unplace 99999 sign unplace 99999
let s:signmode = 1 let s:signmode = 1
let s:sy[a:path].id_top = (s:id_top - 1) let s:sy[a:path].id_top = (s:id_top - 1)
let s:path = a:path
endfunction endfunction
" Functions -> s:stop() {{{2 " Functions -> s:stop() {{{2
@ -466,7 +465,7 @@ endfunction
" Functions -> s:toggle_signify() {{{2 " Functions -> s:toggle_signify() {{{2
function! s:toggle_signify() abort function! s:toggle_signify() abort
if empty(s:path) if empty(s:path)
echo "signify: I don't sy empty buffers!" echo 'signify: I cannot sy empty buffers!'
return return
endif endif
@ -478,11 +477,18 @@ function! s:toggle_signify() abort
let s:sy[s:path].active = 1 let s:sy[s:path].active = 1
call s:start(s:path) call s:start(s:path)
endif endif
else
call s:start(s:path)
endif endif
endfunction endfunction
" Functions -> s:toggle_line_highlighting() {{{2 " Functions -> s:toggle_line_highlighting() {{{2
function! s:toggle_line_highlighting() abort function! s:toggle_line_highlighting() abort
if !has_key(s:sy, s:path)
echo 'signify: I cannot detect any changes!'
return
endif
if s:line_highlight if s:line_highlight
sign define SignifyAdd text=+ texthl=SignifyAdd linehl=none sign define SignifyAdd text=+ texthl=SignifyAdd linehl=none
sign define SignifyChange text=! texthl=SignifyChange linehl=none sign define SignifyChange text=! texthl=SignifyChange linehl=none
@ -504,13 +510,13 @@ function! s:toggle_line_highlighting() abort
let s:line_highlight = 1 let s:line_highlight = 1
endif endif
call s:start(s:file) call s:start(s:path)
endfunction endfunction
" Functions -> s:jump_to_next_hunk() {{{2 " Functions -> s:jump_to_next_hunk() {{{2
function! s:jump_to_next_hunk(count) function! s:jump_to_next_hunk(count)
if !has_key(s:sy, s:path) || s:sy[s:path].id_jump == -1 if !has_key(s:sy, s:path) || s:sy[s:path].id_jump == -1
echo "signify: I cannot detect any changes!" echo 'signify: I cannot detect any changes!'
return return
endif endif
@ -533,7 +539,7 @@ endfunction
" Functions -> s:jump_to_prev_hunk() {{{2 " Functions -> s:jump_to_prev_hunk() {{{2
function! s:jump_to_prev_hunk(count) function! s:jump_to_prev_hunk(count)
if !has_key(s:sy, s:path) || s:sy[s:path].id_jump == -1 if !has_key(s:sy, s:path) || s:sy[s:path].id_jump == -1
echo "signify: I cannot detect any changes!" echo 'signify: I cannot detect any changes!'
return return
endif endif