Skip to content

Commit c68420a

Browse files
authored
Fix some off-by-one at the end of the line in tree sitter (microsoft#229833)
Part of microsoft#229808
1 parent a6139a4 commit c68420a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,11 @@ class TreeSitterTokenizationSupport extends Disposable implements ITreeSitterTok
239239
}
240240
}
241241

242+
// Account for uncaptured characters at the end of the line
242243
if (captures[captures.length - 1].node.endPosition.column + 1 < lineLength) {
243244
increaseSizeOfTokensByOneToken();
244-
endOffsetsAndScopes[tokenIndex].endOffset = lineLength;
245+
endOffsetsAndScopes[tokenIndex].endOffset = lineLength - 1;
246+
tokenIndex++;
245247
}
246248

247249
const tokens: Uint32Array = new Uint32Array((tokenIndex) * 2);

0 commit comments

Comments
 (0)