fix: TK functions no longer override default registers (#184)

This commit is contained in:
aidangrigg
2023-06-04 10:12:58 +10:00
parent 557b960887
commit 68c2f50ca3

View File

@@ -1323,8 +1323,10 @@ local function PreviewImg(opts)
return return
end end
local saved_reg = vim.fn.getreg('"0')
vim.cmd("normal yi)") vim.cmd("normal yi)")
local fname = vim.fn.getreg('"0'):gsub("^img/", "") local fname = vim.fn.getreg('"0'):gsub("^img/", "")
vim.fn.setreg('"0', saved_reg)
-- check if fname exists anywhere -- check if fname exists anywhere
local imageDir = M.Cfg.image_subdir or M.Cfg.home local imageDir = M.Cfg.image_subdir or M.Cfg.home
@@ -1429,8 +1431,11 @@ local function FindFriends(opts)
return return
end end
local saved_reg = vim.fn.getreg('"0')
vim.cmd("normal yi]") vim.cmd("normal yi]")
local title = vim.fn.getreg('"0') local title = vim.fn.getreg('"0')
vim.fn.setreg('"0', saved_reg)
title = linkutils.remove_alias(title) title = linkutils.remove_alias(title)
title = title:gsub("^(%[)(.+)(%])$", "%2") title = title:gsub("^(%[)(.+)(%])$", "%2")
@@ -2003,6 +2008,7 @@ local function FollowLink(opts)
search_mode = "tag" search_mode = "tag"
title = tag title = tag
else else
local saved_reg = vim.fn.getreg('"0')
if kind == "link" then if kind == "link" then
-- we are in a link -- we are in a link
vim.cmd("normal yi]") vim.cmd("normal yi]")
@@ -2015,6 +2021,7 @@ local function FollowLink(opts)
local url = vim.fn.getreg('"0') local url = vim.fn.getreg('"0')
return follow_url(url) return follow_url(url)
end end
vim.fn.setreg('"0', saved_reg)
local parts = vim.split(title, "#") local parts = vim.split(title, "#")