only call os_home once; conditionally replace homedir

This commit is contained in:
Senghan Bright 2021-01-19 05:39:25 +01:00
parent e52c61c312
commit 84443967fc

View File

@ -13,8 +13,9 @@ local path = require('telescope.path')
local pickers = require "telescope.pickers"
local sorters = require "telescope.sorters"
local utils = require('telescope.utils')
local frecency_utils = require("telescope._extensions.frecency.util")
-- local os_path_sep = vim.loop.os_uname().sysname == "Windows" and "\\" or "/"
local os_home = vim.loop.os_homedir()
local os_path_sep = utils.get_separator()
local show_scores = false
local db_client
@ -55,8 +56,9 @@ local frecency = function(opts)
filename = path.make_relative(filename, cwd)
local homedir = vim.loop.os_homedir()
filename = "~/" .. path.make_relative(filename, homedir)
if frecency_utils.string_starts(filename, os_home) then
filename = "~/" .. path.make_relative(filename, os_home)
end
display_items = show_scores and {{entry.score, "Directory"}} or {}
table.insert(display_items, {filename, hl_filename})