fix(treesitter): show proper node name error messages

**Problem:** Currently node names with non-alphanumeric, non
underscore/hyphen characters (only possible with anonymous nodes) are
not given a proper error message. See tree-sitter issue 3892 for more
details.

**Solution:** Apply a different scanning logic to anonymous nodes to
correctly identify the entire node name (i.e., up until the final double
quote)
This commit is contained in:
Riley Bruins
2024-11-08 11:42:09 -08:00
committed by Christian Clason
parent 37f665c504
commit 36990f324d
2 changed files with 36 additions and 3 deletions

View File

@@ -722,7 +722,25 @@ void ui_refresh(void)
eq(exp, pcall_err(exec_lua, "vim.treesitter.query.parse('c', ...)", cquery))
end
-- Invalid node type
-- Invalid node types
test(
'.../query.lua:0: Query error at 1:2. Invalid node type ">\\">>":\n'
.. '">\\">>" @operator\n'
.. ' ^',
'">\\">>" @operator'
)
test(
'.../query.lua:0: Query error at 1:2. Invalid node type "\\\\":\n'
.. '"\\\\" @operator\n'
.. ' ^',
'"\\\\" @operator'
)
test(
'.../query.lua:0: Query error at 1:2. Invalid node type ">>>":\n'
.. '">>>" @operator\n'
.. ' ^',
'">>>" @operator'
)
test(
'.../query.lua:0: Query error at 1:2. Invalid node type "dentifier":\n'
.. '(dentifier) @variable\n'