mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
fix: add fs.joinpath to work in v0.9.0 (#118)
* test: work tests for async_finder I noticed these tests do not work because of vim.fs.joinpath lacking. I will enable these tests and fix the bug. * feat: implement vim.fs.joinpath to work in v0.9.0
This commit is contained in:
parent
251fdb32d2
commit
509288ef3d
@ -36,12 +36,12 @@ AsyncFinder.new = function(fs, path, entry_maker, initial_results)
|
|||||||
if self.closed then
|
if self.closed then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
local fullpath = vim.fs.joinpath(path, name)
|
local fullpath = fs:joinpath(path, name)
|
||||||
if not seen[fullpath] then
|
if not seen[fullpath] then
|
||||||
seen[fullpath] = true
|
seen[fullpath] = true
|
||||||
index = index + 1
|
index = index + 1
|
||||||
count = count + 1
|
count = count + 1
|
||||||
local entry = entry_maker { id = 0, count = 0, path = vim.fs.joinpath(path, name), score = 0 }
|
local entry = entry_maker { id = 0, count = 0, path = fs:joinpath(path, name), score = 0 }
|
||||||
if entry then
|
if entry then
|
||||||
entry.index = index
|
entry.index = index
|
||||||
table.insert(self.entries, entry)
|
table.insert(self.entries, entry)
|
||||||
|
|||||||
@ -29,6 +29,19 @@ FS.new = function(config)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This is needed for Neovim v0.9.0.
|
||||||
|
---@param ... string
|
||||||
|
---@return string
|
||||||
|
function FS:joinpath(...)
|
||||||
|
if vim.fs.joinpath then
|
||||||
|
return vim.fs.joinpath(...)
|
||||||
|
end
|
||||||
|
local function join_paths(...)
|
||||||
|
return (table.concat({ ... }, "/"):gsub("//+", "/"))
|
||||||
|
end
|
||||||
|
return join_paths(...)
|
||||||
|
end
|
||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function FS:is_valid_path(path)
|
function FS:is_valid_path(path)
|
||||||
@ -45,13 +58,13 @@ function FS:scan_dir(path)
|
|||||||
vim.fs.dir(path, {
|
vim.fs.dir(path, {
|
||||||
depth = self.config.scan_depth,
|
depth = self.config.scan_depth,
|
||||||
skip = function(dirname)
|
skip = function(dirname)
|
||||||
if self:is_ignored(vim.fs.joinpath(path, dirname)) then
|
if self:is_ignored(self:joinpath(path, dirname)) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
do
|
do
|
||||||
local fullpath = vim.fs.joinpath(path, name)
|
local fullpath = self:joinpath(path, name)
|
||||||
if type == "file" and not self:is_ignored(fullpath) and gitignore({ path }, fullpath) then
|
if type == "file" and not self:is_ignored(fullpath) and gitignore({ path }, fullpath) then
|
||||||
coroutine.yield(name)
|
coroutine.yield(name)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -28,14 +28,6 @@ local function with_files(files, initial_results, callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe("async_finder", function()
|
describe("async_finder", function()
|
||||||
---@diagnostic disable-next-line: param-type-mismatch
|
|
||||||
if vim.version.eq(vim.version(), "0.9.0") then
|
|
||||||
it("skips these tests for v0.9.0", function()
|
|
||||||
assert.are.same(true, true)
|
|
||||||
end)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local function run(async_finder)
|
local function run(async_finder)
|
||||||
local count = { process_result = 0, process_complete = 0 }
|
local count = { process_result = 0, process_complete = 0 }
|
||||||
local results = {}
|
local results = {}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user