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

Parse with callback can't be cancelled #3

Open
ObserverOfTime opened this issue Jun 23, 2024 · 1 comment
Open

Parse with callback can't be cancelled #3

ObserverOfTime opened this issue Jun 23, 2024 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ObserverOfTime
Copy link
Member

The parse(String) method can be cancelled, but the parse(ParseCallback) method cannot.
Neither the timeout nor the cancellation flag work and I have no idea why.

@ObserverOfTime ObserverOfTime added bug Something isn't working help wanted Extra attention is needed labels Jun 23, 2024
@Sigma42
Copy link

Sigma42 commented Oct 1, 2024

I think cancelation works (on the current treesitter versions), and the problem is just the callback of the test(s).

With a callback like:

ParseCallback callback = (offset, p) -> source.substring(offset, Integer.min(offset, source.length()));

and a starting offset of 0 it will be source.substring(0,0) and that will always be "".
Then treesitter interprets that as:

If the callback reads, at least one byte each time it's called, it parses the file correctly, and it is canceled by flag and by timeout.
Examples (all of these tests succeed locally on my machine):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants