-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tsc-current-field
doesn't work against starting node
#273
Comments
This is apparently an issue for all traversal utils, for example: ;; This will also always return nil
(defun node-field (node)
(block nil
(tsc-traverse-do ([field] node)
(return field)))) |
I think it's the same issue as tree-sitter/tree-sitter#567. |
Hmm, is it a shortcoming in the underlying treesitter API, or is there some functionality that's present in the base API but not exposed by |
Also, I don't know whether that is a thing that even makes sense to want, but this limitation means we can never have a field on the root node of a tree. |
I did some more reading, and it turns out I was confused about the meaning of fields. I was under the impression that fields were the properties of nodes, but in reality, they're properties of the relationship between a parent and its children. So the API really doesn't have a concept of "a node's field", only "given child's field". |
Yes, I found this confusing as well, but IIUC, this is close to my impression of how things work (my impression is vague (^^; ):
|
Yeah, Semi-formally, it's the (name of the) edge between the parent node and the child node. |
It seems that
tsc-current-field
always returnsnil
when run against the cursor's starting node, ie.(tsc-current-field (tsc-make-cursor node)) ; Always returns nil
This is not the case when navigating to other nodes via the cursor. Here's a repro that demonstrates it:
This results in the following output in
*Messages*
:Notice that the output is identical, except for the fields.
Version information:
The text was updated successfully, but these errors were encountered: