Revert "Fix tagrelative option not considered in builtin.tags (#2583)" (#2629)

This reverts commit 6074847b6e due to
performance regression.
This commit is contained in:
James Trew
2023-07-31 20:22:53 -04:00
committed by GitHub
parent b6fccfb0f7
commit d2e17ba18a
2 changed files with 4 additions and 27 deletions

View File

@@ -529,23 +529,6 @@ files.current_buffer_fuzzy_find = function(opts)
end end
files.tags = function(opts) files.tags = function(opts)
-- find lines not matching tags file format (begins with !) or empty lines.
local tags_command = (function()
if 1 == vim.fn.executable "rg" then
return { "rg", "-H", "-N", "--no-heading", "--color", "never", "-v", "^!|^$" }
elseif 1 == vim.fn.executable "grep" then
return { "grep", "-H", "--color=never", "-v", "^!\\|^$" }
end
end)()
if not tags_command then
utils.notify("builtin.tags", {
msg = "You need to install either grep or rg",
level = "ERROR",
})
return
end
local tagfiles = opts.ctags_file and { opts.ctags_file } or vim.fn.tagfiles() local tagfiles = opts.ctags_file and { opts.ctags_file } or vim.fn.tagfiles()
for i, ctags_file in ipairs(tagfiles) do for i, ctags_file in ipairs(tagfiles) do
tagfiles[i] = vim.fn.expand(ctags_file, true) tagfiles[i] = vim.fn.expand(ctags_file, true)
@@ -562,7 +545,7 @@ files.tags = function(opts)
pickers pickers
.new(opts, { .new(opts, {
prompt_title = "Tags", prompt_title = "Tags",
finder = finders.new_oneshot_job(flatten { tags_command, tagfiles }, opts), finder = finders.new_oneshot_job(flatten { "cat", tagfiles }, opts),
previewer = previewers.ctags.new(opts), previewer = previewers.ctags.new(opts),
sorter = conf.generic_sorter(opts), sorter = conf.generic_sorter(opts),
attach_mappings = function() attach_mappings = function()

View File

@@ -1086,9 +1086,9 @@ function make_entry.gen_from_ctags(opts)
local current_file_cache = {} local current_file_cache = {}
return function(line) return function(line)
local tag_file if line == "" or line:sub(1, 1) == "!" then
-- split line by ':' return nil
tag_file, line = string.match(line, "([^:]+):(.+)") end
local tag, file, scode, lnum local tag, file, scode, lnum
-- ctags gives us: 'tags\tfile\tsource' -- ctags gives us: 'tags\tfile\tsource'
@@ -1098,12 +1098,6 @@ function make_entry.gen_from_ctags(opts)
tag, file, lnum = string.match(line, "([^\t]+)\t([^\t]+)\t(%d+).*") tag, file, lnum = string.match(line, "([^\t]+)\t([^\t]+)\t(%d+).*")
end end
-- append tag file path
if vim.opt.tagrelative:get() then
local tag_path = Path:new(tag_file):parent()
file = Path:new(tag_path .. "/" .. file):normalize(cwd)
end
if Path.path.sep == "\\" then if Path.path.sep == "\\" then
file = string.gsub(file, "/", "\\") file = string.gsub(file, "/", "\\")
end end