From def7bf0741225c8057e96879440314e069a860ec Mon Sep 17 00:00:00 2001 From: remvn <34063162+remvn@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:47:15 +0700 Subject: [PATCH 1/3] fix: bookmark filter should include parent directory --- lua/nvim-tree/explorer/filters.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/nvim-tree/explorer/filters.lua b/lua/nvim-tree/explorer/filters.lua index 395e3927b75..d384643cc9b 100644 --- a/lua/nvim-tree/explorer/filters.lua +++ b/lua/nvim-tree/explorer/filters.lua @@ -73,7 +73,17 @@ 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 + + for p, _ in pairs(bookmarks) do + if path == p or utils.str_find(p, path) then + return false + end + end + + return true end ---@param path string From 49d85b44463b9cf2101c67217024a4fc30c5c1af Mon Sep 17 00:00:00 2001 From: remvn <34063162+remvn@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:06:50 +0700 Subject: [PATCH 2/3] fix: dont match mark's siblings --- lua/nvim-tree/explorer/filters.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree/explorer/filters.lua b/lua/nvim-tree/explorer/filters.lua index d384643cc9b..21444ae21a8 100644 --- a/lua/nvim-tree/explorer/filters.lua +++ b/lua/nvim-tree/explorer/filters.lua @@ -77,8 +77,11 @@ local function bookmark(path, bookmarks) return false end - for p, _ in pairs(bookmarks) do - if path == p or utils.str_find(p, path) then + -- add trailing slash to make it match only mark's parent directory + -- not it's siblings + local dict = utils.path_add_trailing(path) + for mark, _ in pairs(bookmarks) do + if path == mark or utils.str_find(mark, dict) then return false end end From 8672b92da49b9a9c76da63b5c25a2b208d13038f Mon Sep 17 00:00:00 2001 From: remvn <34063162+remvn@users.noreply.github.com> Date: Thu, 14 Mar 2024 22:52:59 +0700 Subject: [PATCH 3/3] fix: match mark from the start --- lua/nvim-tree/explorer/filters.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree/explorer/filters.lua b/lua/nvim-tree/explorer/filters.lua index 21444ae21a8..990453455b3 100644 --- a/lua/nvim-tree/explorer/filters.lua +++ b/lua/nvim-tree/explorer/filters.lua @@ -79,9 +79,9 @@ local function bookmark(path, bookmarks) -- add trailing slash to make it match only mark's parent directory -- not it's siblings - local dict = utils.path_add_trailing(path) + local parent = utils.path_add_trailing(path) for mark, _ in pairs(bookmarks) do - if path == mark or utils.str_find(mark, dict) then + if path == mark or vim.fn.stridx(mark, parent) == 0 then return false end end