Skip to content

Commit fc29544

Browse files
committed
fix(previewer): ctag/helptag curosr (closes #2669)
1 parent ab73718 commit fc29544

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

lua/fzf-lua/actions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ M.vimcmd_entry = function(vimcmd, selected, opts, bufedit)
263263
-- (2) save dialog cancellation
264264
pcall(utils.jump_to_location, { uri = entry.uri, range = entry.range }, "utf-16",
265265
opts.reuse_win)
266-
elseif entry.line == 0 and entry.ctag then
266+
elseif (not entry.line or entry.line == 0) and entry.ctag then
267267
local re = utils.ctag_to_magic(entry.ctag)
268268
if utils.vim_regex(re, opts) then
269269
vim.api.nvim_win_set_cursor(0, { 1, 0 })

lua/fzf-lua/previewer/builtin.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,16 +1265,15 @@ function Previewer.buffer_or_file:set_cursor_hl(entry)
12651265
if type(cached_pos) ~= "table" then cached_pos = nil end
12661266
local lnum, col = entry.line, math.max(1, entry.col or 1)
12671267

1268-
if not lnum and regex then
1268+
if (not lnum or lnum == 0) and regex then
12691269
-- pcall(fn.clearmatches, self.win.preview_winid)
12701270
pcall(api.nvim_win_call, win, function()
12711271
-- start searching at line 1 in case we
12721272
-- didn't reload the buffer (same file)
12731273
api.nvim_win_set_cursor(0, { 1, 0 })
12741274
fn.clearmatches()
1275-
local ctag = utils.ctag_to_magic(assert(regex))
12761275
-- test the regex so we can alert the user of the search fail
1277-
if not utils.vim_regex(ctag, self.opts) then return end
1276+
if not utils.vim_regex(regex, self.opts) then return end
12781277
fn.search(regex, "W")
12791278
if hls.search then fn.matchadd(hls.search, regex) end
12801279
self.orig_pos = api.nvim_win_get_cursor(0)
@@ -1421,7 +1420,7 @@ function Previewer.help_tags:parse_entry(entry_str)
14211420
end
14221421
local vimdoc = entry_str:match(string.format("[^%s]+$", utils.nbsp))
14231422
assert(vimdoc and #vimdoc > 0, "help_tags entry missing vimdoc path")
1424-
local hregex = (function()
1423+
local ctag = (function()
14251424
-- lazy.nvim can generate helptags from markdown
14261425
-- https://github.com/folke/lazy.nvim/blob/56a34a825b55e0e30cd9df0e055e428a13afd4aa/lua/lazy/help.lua#L35
14271426
if package.loaded.lazy and vimdoc:match("%.md$") then
@@ -1433,11 +1432,10 @@ function Previewer.help_tags:parse_entry(entry_str)
14331432
end
14341433
end
14351434
end
1436-
return ([[\V*%s*]]):format(tag:gsub([[\]], [[\\]]))
1435+
return tag
14371436
end)()
14381437
return {
1439-
htag = tag,
1440-
ctag = hregex,
1438+
ctag = ctag,
14411439
path = vimdoc,
14421440
}
14431441
end

0 commit comments

Comments
 (0)