tree-sitter
tree-sitter copied to clipboard
Support for testing lack of highlighting
Maybe I missed it, but there currently doesn’t seem to be a way to test the lack of highlighting, or to negate a given class. I would suggest an exclamation mark to negate a given highlighting class, and maybe a lone exclamation mark to state that there should be no highlighting at all
const f1 = ({y: x}) => x;
// ^ !operator
// Tests that the colon is not being given the "operator" highlight
const f2 = ({y: x}) => x;
// ^ !
// Tests that the equal sign is not being given any highlight
To test the complete lack of highlighting, another suggestion would be to use "none"
const f2 = ({y: x}) => x;
// ^ none
// Tests that the equal sign is not being given any highlight
It currently fails with the error message
Failure - row: x, column: y, expected highlight 'none', actual highlights: none.
Of course it would clash if someone were to define a highlight name called "none", but I’m not sure if anyone would want to do that.
Negations in tests are a thing now, I hope that fits your use case.