From 883d959b60258251b3890bb1240d4086adaf7707 Mon Sep 17 00:00:00 2001 From: Lyz Date: Fri, 22 Nov 2024 16:12:51 +0100 Subject: [PATCH] fix: allow query to tags agenda api --- lua/orgmode/agenda/views/tags.lua | 13 ++++++++++--- lua/orgmode/api/agenda.lua | 10 +++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lua/orgmode/agenda/views/tags.lua b/lua/orgmode/agenda/views/tags.lua index 35ba09d2e..50f65260d 100644 --- a/lua/orgmode/agenda/views/tags.lua +++ b/lua/orgmode/agenda/views/tags.lua @@ -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, @@ -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 diff --git a/lua/orgmode/api/agenda.lua b/lua/orgmode/api/agenda.lua index 3acf8de47..17db0ee4d 100644 --- a/lua/orgmode/api/agenda.lua +++ b/lua/orgmode/api/agenda.lua @@ -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