Skip to content

Commit

Permalink
Merge pull request #783 from savetheclocktower/tree-sitter-october-fixes
Browse files Browse the repository at this point in the history
[tree-sitter] Fix proliferation of extra injection layers
  • Loading branch information
savetheclocktower authored Oct 23, 2023
2 parents b8a88fd + 1a1fe62 commit 87bb06b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/wasm-tree-sitter-language-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3838,12 +3838,18 @@ class LanguageLayer {
if (existingInjectionMarkers.length > 0) {
// Enlarge our range to contain all of the injection zones in the
// affected buffer range.
range = range.union(
new Range(
existingInjectionMarkers[0].getRange().start,
last(existingInjectionMarkers).getRange().end
)
);
let earliest, latest;
for (let marker of existingInjectionMarkers) {
range = marker.getRange();
if (!earliest || range.start.compare(earliest) === -1) {
earliest = range.start;
}
if (!latest || range.end.compare(latest) === 1) {
latest = range.end;
}
}

range = range.union(new Range(earliest, latest));
}

// Now that we've enlarged the range, we might have more existing injection
Expand Down

0 comments on commit 87bb06b

Please sign in to comment.