@@ -76,7 +76,7 @@ function Capture:open_template(template)
76
76
vim .api .nvim_buf_set_var (0 , ' org_capture' , true )
77
77
config :setup_mappings (' capture' )
78
78
79
- vim .api .nvim_create_autocmd (' BufWipeout' , {
79
+ self . wipeout_autocmd_id = vim .api .nvim_create_autocmd (' BufWipeout' , {
80
80
buffer = 0 ,
81
81
group = capture_augroup ,
82
82
callback = function ()
@@ -118,11 +118,11 @@ function Capture:refile(confirm)
118
118
self :_refile_to_end (file , lines )
119
119
end
120
120
121
- vim . api . nvim_create_autocmd ( ' BufWipeout ' , {
122
- buffer = 0 ,
123
- group = capture_augroup ,
124
- command = ' silent! wq ' ,
125
- } )
121
+ if self . wipeout_autocmd_id then
122
+ vim . api . nvim_del_autocmd ( self . wipeout_autocmd_id )
123
+ self . wipeout_autocmd_id = nil
124
+ end
125
+ vim . cmd ( ' silent! wq ' )
126
126
end , 0 )
127
127
end
128
128
@@ -307,13 +307,11 @@ function Capture.autocomplete_refile(arg_lead)
307
307
end
308
308
309
309
function Capture :kill ()
310
- vim .api .nvim_create_autocmd (' BufWipeout' , {
311
- buffer = 0 ,
312
- group = capture_augroup ,
313
- callback = function ()
314
- return vim .api .nvim_win_close (0 , true )
315
- end ,
316
- })
310
+ if self .wipeout_autocmd_id then
311
+ vim .api .nvim_del_autocmd (self .wipeout_autocmd_id )
312
+ self .wipeout_autocmd_id = nil
313
+ end
314
+ return vim .api .nvim_win_close (0 , true )
317
315
end
318
316
319
317
return Capture
0 commit comments