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

DocumentBuild.waitUntil doesn't resolve if document exists and is already in desired state #1827

Open
colin-grant-work opened this issue Mar 6, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@colin-grant-work
Copy link

colin-grant-work commented Mar 6, 2025

Langium version: 3.3.0
Package name: langium

Steps To Reproduce

  1. Add a document to the document cache.
  2. Ask the document builder to build that document.
  3. Wait until the document has finished building.
  4. Call .waitUntil with the desired state.
  5. The promise will not resolve if the document is already in the desired state.

The current check requires that the document be in a more advanced state than the requested state:

if (uri) {
const document = this.langiumDocuments.getDocument(uri);
if (document && document.state > state) {
return Promise.resolve(uri);
}
}

On the other hand, the fallback check for the workspace only requires the same or more advanced state:

if (this.currentState >= state) {
return Promise.resolve(undefined);
} else if (cancelToken.isCancellationRequested) {
return Promise.reject(OperationCancelled);
}

Link to code example:

The current behavior

waitUntil never resolves (unless the document is rebuilt later) if the document is available in the target state.

The expected behavior

waitUntil should resolve immediately if the document is already available in the desired state. Or at least that's what I think I'd expect.

@colin-grant-work colin-grant-work added the bug Something isn't working label Mar 6, 2025
@msujew
Copy link
Member

msujew commented Mar 6, 2025

Ah, damn. That was supposed to be a >=. I'll submit a fix for that tomorrow :)

@colin-grant-work
Copy link
Author

That was supposed to be a >=.

Thought so, but I just started working with Langium, so I didn't want to assume there was a reason I couldn't divine. :-)

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

No branches or pull requests

2 participants