Skip to content

Commit

Permalink
fix: allow query to tags agenda api
Browse files Browse the repository at this point in the history
  • Loading branch information
lyz-code committed Nov 22, 2024
1 parent 1d8c9b9 commit 883d959
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 10 additions & 3 deletions lua/orgmode/agenda/views/tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function AgendaTagsView:new(opts)
highlights = {},
items = {},
search = opts.search or '',
query = opts.query or '',
todo_only = opts.todo_only or false,
filters = opts.filters or AgendaFilter:new(),
header = opts.org_agenda_overriding_header,
Expand All @@ -34,9 +35,15 @@ function AgendaTagsView:new(opts)
end

function AgendaTagsView:build()
local tags = vim.fn.OrgmodeInput('Match: ', self.search, function(arg_lead)
return utils.prompt_autocomplete(arg_lead, self.files:get_tags())
end)
local tags
-- Ugly fix until https://github.com/nvim-orgmode/orgmode/issues/483 is fixed
if self.query ~= '' then
tags = self.query
else
tags = vim.fn.OrgmodeInput('Match: ', self.search, function(arg_lead)
return utils.prompt_autocomplete(arg_lead, self.files:get_tags())
end)
end
if vim.trim(tags) == '' then
return utils.echo_warning('Invalid tag.')
end
Expand Down
10 changes: 7 additions & 3 deletions lua/orgmode/api/agenda.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ function OrgAgenda.tags(options)
if options.filters and options.filters ~= '' then
orgmode.agenda.filters:parse(options.filters, true)
end
orgmode.agenda:tags({
todo_only = options.todo_only,
})
-- Ugly fix until https://github.com/nvim-orgmode/orgmode/issues/483 is fixed
options.todo_only = true
options.query = options.query or ''
orgmode.agenda:tags(options)
-- orgmode.agenda:tags({
-- todo_only = options.todo_only,
-- })
end

return OrgAgenda

0 comments on commit 883d959

Please sign in to comment.