summaryrefslogtreecommitdiff
path: root/lua/telescope/make_entry.lua
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2021-09-10 08:48:41 +0200
committerGitHub <noreply@github.com>2021-09-10 08:48:41 +0200
commitd2b768983cc7be755d255649cfd0d998b11bd203 (patch)
tree2993a3c8c1d0dbbe385beed6f7094bf5025e29f3 /lua/telescope/make_entry.lua
parent55ec6c5c9c6d70219334c62b1fee4a73bb80cb6f (diff)
fix: jump to tag if buffer has unsaved changes (#1230)
Diffstat (limited to 'lua/telescope/make_entry.lua')
-rw-r--r--lua/telescope/make_entry.lua36
1 files changed, 21 insertions, 15 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua
index 14d5ecb..f6fed2d 100644
--- a/lua/telescope/make_entry.lua
+++ b/lua/telescope/make_entry.lua
@@ -883,6 +883,17 @@ function make_entry.gen_from_ctags(opts)
end
end
+ local mt = {}
+ mt.__index = function(t, k)
+ if k == "path" then
+ local retpath = Path:new({ t.filename }):absolute()
+ if not vim.loop.fs_access(retpath, "R", nil) then
+ retpath = t.filename
+ end
+ return retpath
+ end
+ end
+
return function(line)
if line == "" or line:sub(1, 1) == "!" then
return nil
@@ -900,26 +911,21 @@ function make_entry.gen_from_ctags(opts)
return nil
end
- local ordinal
-
+ local tag_entry = {}
if opts.only_sort_tags then
- ordinal = tag
+ tag_entry.ordinal = tag
else
- ordinal = file .. ": " .. tag
+ tag_entry.ordinal = file .. ": " .. tag
end
- return {
- valid = true,
- ordinal = ordinal,
- display = make_display,
- scode = scode,
- tag = tag,
+ tag_entry.display = make_display
+ tag_entry.scode = scode
+ tag_entry.tag = tag
+ tag_entry.filename = file
+ tag_entry.col = 1
+ tag_entry.lnum = lnum and tonumber(lnum) or 1
- filename = file,
-
- col = 1,
- lnum = lnum and tonumber(lnum) or 1,
- }
+ return setmetatable(tag_entry, mt)
end
end