Skip to content

Commit

Permalink
fix(typescript): prune semanticTokens that are out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jun 23, 2024
1 parent 22af0fd commit 5a211a5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/typescript/lib/semanticFeatures/semanticTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ export function register(ts: typeof import('typescript'), ctx: SharedContext) {
tokenModifiersTable[TokenModifier.defaultLibrary] = 1 << legend.tokenModifiers.indexOf('defaultLibrary');
tokenModifiersTable = tokenModifiersTable.map(mod => Math.max(mod, 0));

const end = start + length;
const tokenSpan = response.spans;
const tokens: [number, number, number, number, number][] = [];
let i = 0;
while (i < tokenSpan.length) {
const offset = tokenSpan[i++];
if (offset >= end) {
break;
}
const length = tokenSpan[i++];
const tsClassification = tokenSpan[i++];

Expand Down

0 comments on commit 5a211a5

Please sign in to comment.