Skip to content

Commit

Permalink
chore(ctags): minor improvements to PR #1550
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Dec 5, 2024
1 parent e356381 commit 865a46f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lua/fzf-lua/make_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ M.tag = function(x, opts)
local line, tag = text:match("(%d-);?(/.*/)")
if not tag then
-- lines with a tag located solely by line number contain nothing but the
-- number at this point
-- number at this point (e.g. using "ctags -R --excmd=number")
line = text:match("%d+")
end
line = line and #line > 0 and tonumber(line)
Expand Down
20 changes: 9 additions & 11 deletions lua/fzf-lua/previewer/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1127,21 +1127,19 @@ function Previewer.tags:new(o, opts, fzf_win)
end

function Previewer.tags:set_cursor_hl(entry)
if tonumber(entry.line) and entry.line > 0 then
Previewer.buffer_or_file.set_cursor_hl(self, entry)
return
end
-- pcall(vim.fn.clearmatches, self.win.preview_winid)
pcall(api.nvim_win_call, self.win.preview_winid, function()
-- start searching at line 1 in case we
-- didn't reload the buffer (same file)
if not entry.line or entry.line == 0 then
api.nvim_win_set_cursor(0, { 1, 0 })
fn.clearmatches()
fn.search(entry.ctag, "W")
if self.win.hls.search then
fn.matchadd(self.win.hls.search, entry.ctag)
end
else
-- the entry's line is assumed to be correct,
-- allowing the search to be skipped
api.nvim_win_set_cursor(0, { entry.line, 0 })
api.nvim_win_set_cursor(0, { 1, 0 })
fn.clearmatches()
fn.search(entry.ctag, "W")
if self.win.hls.search then
fn.matchadd(self.win.hls.search, entry.ctag)
end
self.orig_pos = api.nvim_win_get_cursor(0)
utils.zz()
Expand Down

0 comments on commit 865a46f

Please sign in to comment.