Skip to content

Commit

Permalink
Merge pull request #334 from vim-denops/remove-callback-before
Browse files Browse the repository at this point in the history
🐛 Fix "once" callback leak
  • Loading branch information
lambdalisue committed Apr 17, 2024
2 parents 2d11652 + c151acc commit c727a3f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions autoload/denops/callback.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ function! denops#callback#unregister(id) abort
if !has_key(s:registry, a:id)
return
endif
silent unlet s:registry[a:id]
unlet s:registry[a:id]
endfunction

function! denops#callback#call(id, ...) abort
if !has_key(s:registry, a:id)
throw printf('No callback function for %s exist', a:id)
endif
let l:entry = s:registry[a:id]
let l:ret = call(l:entry.callback, a:000)
if l:entry.options.once
call denops#callback#unregister(a:id)
unlet s:registry[a:id]
endif
return l:ret
return call(l:entry.callback, a:000)
endfunction

function! denops#callback#clear() abort
Expand Down

0 comments on commit c727a3f

Please sign in to comment.