fix: bookmark filter should include parent directory (#2704)

* fix: bookmark filter should include parent directory

* fix: dont match mark's siblings

* fix: match mark from the start

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
remvn 2024-03-15 08:21:04 +07:00 committed by GitHub
parent cfea5bd080
commit 76b98109f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -73,7 +73,20 @@ end
---@param path string
---@param bookmarks table<string, boolean> absolute paths bookmarked
local function bookmark(path, bookmarks)
return M.config.filter_no_bookmark and not bookmarks[path]
if not M.config.filter_no_bookmark then
return false
end
-- add trailing slash to make it match only mark's parent directory
-- not it's siblings
local parent = utils.path_add_trailing(path)
for mark, _ in pairs(bookmarks) do
if path == mark or vim.fn.stridx(mark, parent) == 0 then
return false
end
end
return true
end
---@param path string