fix(lib): check point, byte ranges in ts_query_cursor_set

range functions
This commit is contained in:
WillLillis 2024-11-02 00:44:58 -04:00 committed by Amaan Qureshi
parent 9d86cb2c20
commit 5b5cf5a5e5
6 changed files with 45 additions and 11 deletions

View file

@ -1280,6 +1280,13 @@ class Query {
if (typeof matchLimit !== 'number') {
throw new Error('Arguments must be numbers');
}
if (endIndex != 0 && startIndex > endIndex) {
throw new Error('`startIndex` cannot be greater than `endIndex`');
}
if (endPosition != ZERO_POINT && (startPosition.row > endPosition.row ||
(startPosition.row == endPosition.row && startPosition.column > endPosition.row))) {
throw new Error('`startPosition` cannot be greater than `endPosition`');
}
marshalNode(node);
@ -1345,6 +1352,13 @@ class Query {
if (typeof matchLimit !== 'number') {
throw new Error('Arguments must be numbers');
}
if (endIndex != 0 && startIndex > endIndex) {
throw new Error('`startIndex` cannot be greater than `endIndex`');
}
if (endPosition != ZERO_POINT && (startPosition.row > endPosition.row ||
(startPosition.row == endPosition.row && startPosition.column > endPosition.row))) {
throw new Error('`startPosition` cannot be greater than `endPosition`');
}
marshalNode(node);