treesitter: unknown predicates always match #12173

This commit is contained in:
Thomas Vigouroux 2020-05-01 07:43:30 +02:00 committed by GitHub
parent 42b441738d
commit e5022c61ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,6 +159,9 @@ function Query:match_preds(match, pattern, bufnr)
end
local regexes = self.regexes[pattern]
for i, pred in pairs(preds) do
-- Here we only want to return if a predicate DOES NOT match, and
-- continue on the other case. This way unknown predicates will not be considered,
-- which allows some testing and easier user extensibility (#12173).
if pred[1] == "eq?" then
local node = match[pred[2]]
local node_text = get_node_text(node, bufnr)
@ -184,9 +187,9 @@ function Query:match_preds(match, pattern, bufnr)
if start_row ~= end_row then
return false
end
return regexes[i]:match_line(bufnr, start_row, start_col, end_col)
else
return false
if not regexes[i]:match_line(bufnr, start_row, start_col, end_col) then
return false
end
end
end
return true