From 1b00802aa00707f9fd1aeaa33b937166b8181bf3 Mon Sep 17 00:00:00 2001 From: Christopher Sams Date: Thu, 10 Aug 2023 22:14:44 -0500 Subject: [PATCH] Fix FollowLink when searching tags. When FollowLink is called from the show_tags picker, it searches for the word that was under the cursor instead of the selected tag. This PR changes FollowLink so it instead searches for the selected tag. Signed-off-by: Christopher Sams --- lua/telekasten.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index 00d36a9..e344501 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -2086,6 +2086,7 @@ local function FollowLink(opts) if opts.follow_tag ~= nil then kind = "tag" + title = opts.follow_tag if opts.templateDir ~= nil then globArg = "--glob=!" .. "**/" .. opts.templateDir .. "/*.md" end @@ -2095,10 +2096,12 @@ local function FollowLink(opts) if kind == "tag" then search_mode = "tag" - local saved_reg = vim.fn.getreg('"0') - vim.cmd("normal yiw") - title = vim.fn.getreg('"0') - vim.fn.setreg('"0', saved_reg) + if title == nil then + local saved_reg = vim.fn.getreg('"0') + vim.cmd("normal yiw") + title = vim.fn.getreg('"0') + vim.fn.setreg('"0', saved_reg) + end else local saved_reg = vim.fn.getreg('"0') if kind == "link" then