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>
This commit is contained in:
wyrid 2022-10-28 23:22:14 -04:00 committed by GitHub
parent dd90bfa155
commit 3845039c1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,7 +76,8 @@ function M.apply_filter(node_)
end end
local has_nodes = nodes and (M.always_show_folders or #nodes > filtered_nodes) local has_nodes = nodes and (M.always_show_folders or #nodes > filtered_nodes)
node.hidden = not (has_nodes or matches(node)) local ok, is_match = pcall(matches, node)
node.hidden = not (has_nodes or (ok and is_match))
end end
iterate(node_ or TreeExplorer) iterate(node_ or TreeExplorer)