Skip to content

Commit edc3ceb

Browse files
refactor(capture): Split logic around refiling from org or capture buffer
1 parent 70ce6b7 commit edc3ceb

File tree

8 files changed

+394
-266
lines changed

8 files changed

+394
-266
lines changed

lua/orgmode/agenda/agenda_item.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function AgendaItem:new(headline_date, headline, date, index)
5555
return opts
5656
end
5757

58-
---@param headline Section
58+
---@param headline OrgHeadline
5959
function AgendaItem:set_headline(headline)
6060
self.headline = headline
6161
if self.is_valid then

lua/orgmode/agenda/filter.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ function AgendaFilter:matches(headline)
4343
local tag_cat_match_empty = #self.tags == 0 and #self.categories == 0
4444

4545
if not term_match then
46-
local rgx = vim.regex(self.term)
47-
term_match = rgx:match_str(headline:get_title())
46+
local rgx = vim.regex(self.term) --[[@as vim.regex]]
47+
term_match = rgx:match_str(headline:get_title()) and true or false
4848
end
4949

5050
if tag_cat_match_empty then

lua/orgmode/api/init.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,16 @@ function OrgApi.refile(opts)
8484
end
8585

8686
local source_bufnr = vim.fn.bufnr(opts.source.file.filename) or -1
87+
local is_capture = source_bufnr > -1 and vim.b[source_bufnr].org_capture
8788

88-
if orgmode.capture._window then
89+
if is_capture and orgmode.capture._window then
8990
refile_opts.template = orgmode.capture._window.template
9091
end
9192

92-
orgmode.capture:process_refile(refile_opts)
93-
94-
if source_bufnr > -1 and vim.b[source_bufnr].org_capture then
95-
orgmode.capture:kill()
93+
if is_capture then
94+
orgmode.capture:_refile_from_capture_buffer(refile_opts)
95+
else
96+
orgmode.capture:_refile_from_org_file(refile_opts)
9697
end
9798

9899
return true

0 commit comments

Comments
 (0)