@@ -6,7 +6,7 @@ local Promise = require('orgmode.utils.promise')
66--- @field template OrgCaptureTemplate
77--- @field on_open ? fun ( self : OrgCaptureWindow )
88--- @field on_finish ? fun ( lines : string[] ): string[] | nil
9- --- @field on_close ? fun ()
9+ --- @field on_close ? fun ( self : OrgCaptureWindow )
1010
1111--- @class OrgCaptureWindow : OrgCaptureWindowOpts
1212--- @field private _window fun () | nil
@@ -34,7 +34,7 @@ function CaptureWindow:open()
3434 if not content then
3535 return utils .echo_info (' Canceled.' )
3636 end
37- self ._window = utils .open_tmp_org_window (16 , config .win_split_mode , config .win_border , self . on_close )
37+ self ._window = utils .open_tmp_org_window (16 , config .win_split_mode , config .win_border , self : _on_close () )
3838 vim .api .nvim_buf_set_lines (0 , 0 , - 1 , true , content )
3939 self .template :setup ()
4040 vim .b .org_capture = true
@@ -50,6 +50,15 @@ function CaptureWindow:open()
5050 end )
5151end
5252
53+ function CaptureWindow :_on_close ()
54+ if not self .on_close then
55+ return nil
56+ end
57+ return function ()
58+ self .on_close (self )
59+ end
60+ end
61+
5362function CaptureWindow :finish ()
5463 local result = vim .api .nvim_buf_get_lines (0 , 0 , - 1 , false )
5564 if self .on_finish then
0 commit comments