Add the buffer number as an argument to sy#stop()

sy#stop() is called by the BufDelete autocmd so b: variables may not
correspond to the buffer actually being deleted.  Instead, we must use
<abuf> to determine which buffer is being deleted and pass that into
sy#stop().

There are some ripple effects, causing sy#sign#remove_all_signs to also
gain a buffer number argument.

Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
James McCoy 2014-11-25 11:25:40 -05:00
parent 52cb36801d
commit c61dded98a
3 changed files with 13 additions and 10 deletions

View File

@ -88,15 +88,16 @@ function! sy#start() abort
endfunction endfunction
" Function: #stop {{{1 " Function: #stop {{{1
function! sy#stop() abort function! sy#stop(bufnr) abort
if !exists('b:sy') let sy = getbufvar(a:bufnr, 'sy')
if empty(sy)
return return
endif endif
call sy#sign#remove_all_signs() call sy#sign#remove_all_signs(a:bufnr)
augroup signify augroup signify
execute printf('autocmd! * <buffer=%d>', b:sy.buffer) execute printf('autocmd! * <buffer=%d>', sy.buffer)
augroup END augroup END
endfunction endfunction
@ -108,7 +109,7 @@ function! sy#toggle() abort
endif endif
if b:sy.active if b:sy.active
call sy#stop() call sy#stop(b:sy.buffer)
let b:sy.active = 0 let b:sy.active = 0
let b:sy.stats = [-1, -1, -1] let b:sy.stats = [-1, -1, -1]
else else

View File

@ -189,15 +189,17 @@ function! sy#sign#process_diff(diff) abort
endfunction endfunction
" Function: #remove_all_signs {{{1 " Function: #remove_all_signs {{{1
function! sy#sign#remove_all_signs() abort function! sy#sign#remove_all_signs(bufnr) abort
for hunk in b:sy.hunks let sy = getbufvar(a:bufnr, 'sy')
for hunk in sy.hunks
for id in hunk.ids for id in hunk.ids
execute 'sign unplace' id execute 'sign unplace' id
endfor endfor
endfor endfor
let b:sy.hunks = [] let sy.hunks = []
let b:sy.stats = [0, 0, 0] let sy.stats = [0, 0, 0]
endfunction endfunction
" Function: s:add_sign {{{1 " Function: s:add_sign {{{1

View File

@ -17,7 +17,7 @@ augroup signify
autocmd! autocmd!
autocmd BufRead,BufWritePost * call sy#start() autocmd BufRead,BufWritePost * call sy#start()
autocmd BufDelete * call sy#stop() autocmd BufDelete * call sy#stop(expand('<abuf>'))
autocmd QuickFixCmdPre *vimgrep* let g:signify_locked = 1 autocmd QuickFixCmdPre *vimgrep* let g:signify_locked = 1
autocmd QuickFixCmdPost *vimgrep* let g:signify_locked = 0 autocmd QuickFixCmdPost *vimgrep* let g:signify_locked = 0