Skip to content

Commit 76b9810

Browse files
remvnalex-courtis
andauthored
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 <[email protected]>
1 parent cfea5bd commit 76b9810

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Diff for: lua/nvim-tree/explorer/filters.lua

+14-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,20 @@ end
7373
---@param path string
7474
---@param bookmarks table<string, boolean> absolute paths bookmarked
7575
local function bookmark(path, bookmarks)
76-
return M.config.filter_no_bookmark and not bookmarks[path]
76+
if not M.config.filter_no_bookmark then
77+
return false
78+
end
79+
80+
-- add trailing slash to make it match only mark's parent directory
81+
-- not it's siblings
82+
local parent = utils.path_add_trailing(path)
83+
for mark, _ in pairs(bookmarks) do
84+
if path == mark or vim.fn.stridx(mark, parent) == 0 then
85+
return false
86+
end
87+
end
88+
89+
return true
7790
end
7891

7992
---@param path string

0 commit comments

Comments
 (0)