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

Add event for when tree tokens change #228593

Merged
merged 1 commit into from
Sep 18, 2024
Merged

Conversation

alexr00
Copy link
Member

@alexr00 alexr00 commented Sep 13, 2024

Part of #210475

@alexr00 alexr00 requested a review from hediet September 13, 2024 19:18
@alexr00 alexr00 self-assigned this Sep 13, 2024
@alexr00 alexr00 enabled auto-merge (squash) September 13, 2024 19:18
@vs-code-engineering vs-code-engineering bot added this to the September 2024 milestone Sep 13, 2024
@@ -102,7 +105,13 @@ export class TextModelTreeSitter extends Disposable {
}

private async _onDidChangeContent(treeSitterTree: TreeSitterParseResult, changes: IModelContentChange[]) {
return treeSitterTree.onDidChangeContent(this.model, changes);
const oldTree = treeSitterTree.tree?.copy();
await treeSitterTree.onDidChangeContent(this.model, changes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if that is a problem here, but subsequent onDidChangeContent event calls can make multiple promises to get stuck here.
Then line 110 might cause a race condition, depending on which promise resolves first.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual changes done in onDidChangecontent are queued, so don't think we need to worry about the order in which they are resolved: they will always be sequential.

However, we could end up with this._onDidChangeParseResult firing with the same range multiple times.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attempted to address in #228986.

@alexr00 alexr00 merged commit 3ea0cbb into main Sep 18, 2024
7 checks passed
@alexr00 alexr00 deleted the alexr00/territorial-gamefowl branch September 18, 2024 08:16
@alexr00 alexr00 restored the alexr00/territorial-gamefowl branch September 18, 2024 18:28
@alexr00 alexr00 deleted the alexr00/territorial-gamefowl branch September 18, 2024 20:15
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Nov 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants