Skip to content

Commit

Permalink
Prevent race condition during startup…
Browse files Browse the repository at this point in the history
…related to updating open documents’ syntax highlighting as grammars are processed.
  • Loading branch information
savetheclocktower committed Sep 14, 2024
1 parent 0f0050f commit 99521c7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/wasm-tree-sitter-language-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3031,6 +3031,9 @@ class LanguageLayer {
if (!this.ready) {
params.async = true;
await this.languageLoaded;
// While we were waiting for this language to load, another update may
// have been scheduled.
if (this.currentParsePromise) return false;
}
this.currentParsePromise = this._performUpdate(nodeRangeSet, params);
if (!params.async) { break; }
Expand Down

0 comments on commit 99521c7

Please sign in to comment.