make relative dir setting compatible with tail_path

This commit is contained in:
Senghan Bright 2021-01-19 08:35:39 +01:00
parent 867f0d714d
commit 098edfc941

View File

@ -48,24 +48,21 @@ local frecency = function(opts)
filename = entry.name filename = entry.name
hl_filename = buf_is_loaded(bufnr(filename)) and "TelescopeBufferLoaded" or "" hl_filename = buf_is_loaded(bufnr(filename)) and "TelescopeBufferLoaded" or ""
original_filename = filename
if opts.tail_path then if opts.tail_path then
filename = utils.path_tail(filename) filename = utils.path_tail(filename)
elseif opts.shorten_path then elseif opts.shorten_path then
filename = utils.path_shorten(filename) filename = utils.path_shorten(filename)
end else -- check relative to home/current
original_filename = filename
filename = path.make_relative(filename, cwd) filename = path.make_relative(filename, cwd)
if frecency_utils.string_starts(filename, os_home) then if frecency_utils.string_starts(filename, os_home) then
filename = "~/" .. path.make_relative(filename, os_home) filename = "~/" .. path.make_relative(filename, os_home)
else elseif filename ~= original_filename then
if filename ~= original_filename then
filename = "./" .. filename filename = "./" .. filename
end end
end end
display_items = show_scores and {{entry.score, "Directory"}} or {} display_items = show_scores and {{entry.score, "Directory"}} or {}
table.insert(display_items, {filename, hl_filename}) table.insert(display_items, {filename, hl_filename})