@@ -6,7 +6,7 @@ local Promise = require('orgmode.utils.promise')
6
6
--- @field template OrgCaptureTemplate
7
7
--- @field on_open ? fun ( self : OrgCaptureWindow )
8
8
--- @field on_finish ? fun ( lines : string[] ): string[] | nil
9
- --- @field on_close ? fun ()
9
+ --- @field on_close ? fun ( self : OrgCaptureWindow )
10
10
11
11
--- @class OrgCaptureWindow : OrgCaptureWindowOpts
12
12
--- @field private _window fun () | nil
@@ -34,7 +34,7 @@ function CaptureWindow:open()
34
34
if not content then
35
35
return utils .echo_info (' Canceled.' )
36
36
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 () )
38
38
vim .api .nvim_buf_set_lines (0 , 0 , - 1 , true , content )
39
39
self .template :setup ()
40
40
vim .b .org_capture = true
@@ -50,6 +50,15 @@ function CaptureWindow:open()
50
50
end )
51
51
end
52
52
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
+
53
62
function CaptureWindow :finish ()
54
63
local result = vim .api .nvim_buf_get_lines (0 , 0 , - 1 , false )
55
64
if self .on_finish then
0 commit comments