Skip to content

Commit 3845039

Browse files
attridalex-courtis
andauthored
fix: use pcall to prevent live-filter regex errors (#1689)
* fix: use pcall to prevent live-filter regex errors Wrap live filter's match function in pcall to prevent errors caused by invalid regex while typing. * nit: use ok for pcall rc * nit: stylua fix Co-authored-by: Alexander Courtis <alex@courtis.org>
1 parent dd90bfa commit 3845039

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lua/nvim-tree/live-filter.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ function M.apply_filter(node_)
7676
end
7777

7878
local has_nodes = nodes and (M.always_show_folders or #nodes > filtered_nodes)
79-
node.hidden = not (has_nodes or matches(node))
79+
local ok, is_match = pcall(matches, node)
80+
node.hidden = not (has_nodes or (ok and is_match))
8081
end
8182

8283
iterate(node_ or TreeExplorer)

0 commit comments

Comments
 (0)