Skip to content

Commit

Permalink
fix: return an empty list when field ids are zero
Browse files Browse the repository at this point in the history
  • Loading branch information
wstevick authored Feb 26, 2024
1 parent c0cd1bb commit 0f5d9cf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tree_sitter/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ static PyObject *node_children_by_field_id_internal(Node *self, TSFieldId field_
ModuleState *state = PyType_GetModuleState(Py_TYPE(self));
PyObject *result = PyList_New(0);

if (field_id == 0) {
return result;
}

ts_tree_cursor_reset(&state->default_cursor, self->node);
int ok = ts_tree_cursor_goto_first_child(&state->default_cursor);
while (ok) {
Expand Down

0 comments on commit 0f5d9cf

Please sign in to comment.