Fetch and set semantic tokens in the viewport

This commit is contained in:
Alex Dima
2020-03-25 23:13:44 +01:00
parent 67fbbe4dbe
commit 2da34cd2dd
9 changed files with 360 additions and 281 deletions

View File

@@ -54,7 +54,14 @@ function fromLittleEndianBuffer(buff: VSBuffer): Uint32Array {
// the byte order must be changed
reverseEndianness(uint8Arr);
}
return new Uint32Array(uint8Arr.buffer, uint8Arr.byteOffset);
if (uint8Arr.byteOffset % 4 === 0) {
return new Uint32Array(uint8Arr.buffer, uint8Arr.byteOffset);
} else {
// unaligned memory access doesn't work on all platforms
const data = new Uint8Array(uint8Arr.byteLength);
data.set(uint8Arr);
return new Uint32Array(data.buffer, data.byteOffset);
}
}
export function encodeSemanticTokensDto(semanticTokens: ISemanticTokensDto): VSBuffer {