Skip to content

Commit 2dc1466

Browse files
authored
Merge pull request #2 from lyz-code/fix/refile-close-capture
fix: refile closes the window when in capture mode
2 parents 82126c0 + f577d3b commit 2dc1466

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lua/telescope/_extensions/orgmode/refile_heading.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ local state = require("telescope.state")
88

99
local utils = require('telescope-orgmode.utils')
1010

11+
local orgmode = require('orgmode')
1112
local Files = require('orgmode.parser.files')
1213
local Capture = require('orgmode.capture')
14+
local Range = require('orgmode.parser.range')
1315

1416
return function(opts)
1517
opts = opts or {}
@@ -36,17 +38,23 @@ return function(opts)
3638
local is_same_file = dst_file.filename == src_item.root.filename
3739
src_lines = src_item:demote(dst_headline.level - src_item.level + 1, true, not is_same_file)
3840
end
39-
local refiled = Capture:_refile_to(dst_file.filename, src_lines, src_item, dst_headline.position.end_line)
41+
refile_opts = {
42+
file = dst_file.filename,
43+
lines = src_lines,
44+
item = src_item,
45+
range = Range.from_line(dst_headline.position.end_line),
46+
headline = dst_headline.position.end_line,
47+
}
48+
local refiled = Capture:_refile_to(refile_opts)
4049
if not refiled then
4150
return false
4251
end
43-
--utils.echo_info(string.format('Wrote %s', dst_file.filename))
4452
else
4553
Capture:_refile_to_end(dst_file.filename, src_lines, src_item)
4654
end
4755

4856
if is_capture then
49-
Capture:kill()
57+
orgmode.action('capture.kill')
5058
end
5159
end
5260

0 commit comments

Comments
 (0)