Skip to content

Commit

Permalink
Handle stricter 1.94 type checking wrt Buffer vs Uint8Array
Browse files Browse the repository at this point in the history
  • Loading branch information
gjsjohnmurray committed Sep 30, 2024
1 parent df9d264 commit 119a945
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export async function checkChangedOnServer(file: CurrentTextFile | CurrentBinary
? false
: (content as string[]).every((line, index) => line.trim() == (fileContent[index] || "").trim());
} else {
sameContent = force ? false : Buffer.compare(content as Buffer, file.content) === 0;
sameContent = force
? false
: Buffer.compare(content as unknown as Uint8Array, file.content as unknown as Uint8Array) === 0;
}
const mtime =
force || sameContent ? serverTime : Math.max((await vscode.workspace.fs.stat(file.uri)).mtime, serverTime);
Expand Down Expand Up @@ -243,7 +245,7 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
const content = await api.getDoc(file.name).then((data) => data.result.content);
await vscode.workspace.fs.writeFile(
file.uri,
Buffer.isBuffer(content) ? content : new TextEncoder().encode(content.join("\n"))
Buffer.isBuffer(content) ? (content as unknown as Uint8Array) : new TextEncoder().encode(content.join("\n"))
);
} else if (filesystemSchemas.includes(file.uri.scheme)) {
fileSystemProvider.fireFileChanged(file.uri);
Expand Down
4 changes: 2 additions & 2 deletions src/providers/FileSystemProvider/FileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {

public writeFile(
uri: vscode.Uri,
content: Buffer,
content: Uint8Array,
options: {
create: boolean;
overwrite: boolean;
Expand Down Expand Up @@ -452,7 +452,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
}
// File doesn't exist on the server, and we are allowed to create it.
// Create content (typically a stub, unless the write-phase of a copy operation).
const newContent = generateFileContent(uri, fileName, content);
const newContent = generateFileContent(uri, fileName, content as unknown as Buffer);

// Write it to the server
return api
Expand Down

0 comments on commit 119a945

Please sign in to comment.