Skip to content

Commit 0623f96

Browse files
committed
Fix some FileSystemProvider type errors
Not sure why they didn't show up previously
1 parent abbdc35 commit 0623f96

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
11641164
}
11651165
const fileName = filePathNoWorkspaceArr.join(".");
11661166
// Generate the new content
1167-
const newContent = generateFileContent(uri, fileName, Buffer.from(await vscode.workspace.fs.readFile(uri)));
1167+
const newContent = generateFileContent(uri, fileName, await vscode.workspace.fs.readFile(uri));
11681168
// Write the new content to the file
11691169
return vscode.workspace.fs.writeFile(uri, new TextEncoder().encode(newContent.content.join("\n")));
11701170
})

src/providers/FileSystemProvider/FileSystemProvider.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type Entry = File | Directory;
3030
export function generateFileContent(
3131
uri: vscode.Uri,
3232
fileName: string,
33-
sourceContent: Buffer
33+
sourceContent: Uint8Array
3434
): { content: string[]; enc: boolean } {
3535
const sourceLines = sourceContent.length ? new TextDecoder().decode(sourceContent).split("\n") : [];
3636
const fileExt = fileName.split(".").pop().toLowerCase();
@@ -104,7 +104,7 @@ export function generateFileContent(
104104
}
105105
}
106106
return {
107-
content: [sourceContent.toString("base64")],
107+
content: [Buffer.from(sourceContent).toString("base64")],
108108
enc: true,
109109
};
110110
}
@@ -396,7 +396,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
396396

397397
public writeFile(
398398
uri: vscode.Uri,
399-
content: Buffer,
399+
content: Uint8Array,
400400
options: {
401401
create: boolean;
402402
overwrite: boolean;
@@ -659,11 +659,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
659659
const newCsp = newParams.has("csp") && ["", "1"].includes(newParams.get("csp"));
660660
const newFileName = newCsp ? newUri.path : newUri.path.slice(1).replace(/\//g, ".");
661661
// Generate content for the new file
662-
const newContent = generateFileContent(
663-
newUri,
664-
newFileName,
665-
Buffer.from(await vscode.workspace.fs.readFile(oldUri))
666-
);
662+
const newContent = generateFileContent(newUri, newFileName, await vscode.workspace.fs.readFile(oldUri));
667663
if (newFileStat) {
668664
// We're overwriting an existing file so prompt the user to check it out
669665
await fireOtherStudioAction(OtherStudioAction.AttemptedEdit, newUri);

0 commit comments

Comments
 (0)