From 76b98109f62caa12b2f1dff472060b2233ea2e90 Mon Sep 17 00:00:00 2001 From: remvn <34063162+remvn@users.noreply.github.com> Date: Fri, 15 Mar 2024 08:21:04 +0700 Subject: [PATCH] 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 --- lua/nvim-tree/explorer/filters.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/nvim-tree/explorer/filters.lua b/lua/nvim-tree/explorer/filters.lua index 395e3927..99045345 100644 --- a/lua/nvim-tree/explorer/filters.lua +++ b/lua/nvim-tree/explorer/filters.lua @@ -73,7 +73,20 @@ end ---@param path string ---@param bookmarks table 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