Skip to content
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

TreeCursor.iterate continues iterating over sibling nodes #60

Closed
peaffenzeller opened this issue Oct 16, 2024 · 8 comments
Closed

TreeCursor.iterate continues iterating over sibling nodes #60

peaffenzeller opened this issue Oct 16, 2024 · 8 comments

Comments

@peaffenzeller
Copy link

peaffenzeller commented Oct 16, 2024

The docs for TreeCursor.iterate say

Iterate over the current node and all its descendants, [...]

That would suggest, that siblings of a node are not included when iterating, only its children. But when I create a new cursor for a given node and call iterate on it, it continues iterating also over sibling nodes, see this example.

the new cursor used to iterate over the VariableDeclaration logs both const a = 1 and const b = 2, even though - according to the docs - it should stop after its last child.

@marijnh
Copy link
Contributor

marijnh commented Oct 16, 2024

That was indeed a bug. Attached patch should fix it.

@JClackett
Copy link

Think this has caused a regression, getting: TypeError: undefined is not an object (evaluating 'children.length') now

@marijnh
Copy link
Contributor

marijnh commented Oct 28, 2024

I suspect you upgraded incorrectly, and have duplicated @lezer packages in your node_modules.

@JClackett
Copy link

im using codemirror which depends on lezer apparantly, so dont have lezer in my package json. Reverting to 1.2.2 has solved for now :)

@marijnh
Copy link
Contributor

marijnh commented Oct 28, 2024

yarn upgrade (or npm upgrade in old npm versions) will duplicate some dependencies that are depended on in multiple ways, leading to, for example, instanceof becoming unreliable because classes are loaded multiple times.

@JClackett
Copy link

Sorry im not really sure what you mean, if I look in my lock file after my app started crashing, I see that this package was updated to 1.2.3, so if I set the resolutions property to keep lezer at 1.2.2 it fixes my issues. The stack trace of the error leads back to this package causing the error. Is that not an issue with this package then?

@marijnh
Copy link
Contributor

marijnh commented Oct 29, 2024

In the broken state, what does npm ls -a | grep @lezer give?

@JClackett
Copy link

hmm yeah, actually, if I set the resolutions to 1.2.3 it works as well, so for some reason my lock file changed and there was a broken version or something weird happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants