Skip to content

Commit 428221f

Browse files
Merge pull request #512 from gjsjohnmurray/fix-394
fix #394 don't mangle binary files
2 parents c13c67b + 15ff8b1 commit 428221f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/providers/FileSystemPovider/File.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ export class File implements vscode.FileStat {
88
public fileName: string;
99
public name: string;
1010
public data?: Uint8Array;
11-
public constructor(name: string, fileName: string, ts: string, size: number, data: string) {
11+
public constructor(name: string, fileName: string, ts: string, size: number, data: string | Buffer) {
1212
this.type = vscode.FileType.File;
1313
this.ctime = new Date(ts).getTime();
1414
this.mtime = new Date(ts).getTime();
1515
this.size = size;
1616
this.fileName = fileName;
1717
this.name = name;
18-
this.data = Buffer.from(data);
18+
this.data = typeof data === "string" ? Buffer.from(data) : data;
1919
}
2020
}

src/providers/FileSystemPovider/FileSystemProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
359359
name,
360360
fileName,
361361
ts,
362-
Array.isArray(content) ? content.join("\n").length : String(content).length,
363-
Array.isArray(content) ? content.join("\n") : String(content)
362+
Array.isArray(content) ? content.join("\n").length : content.length,
363+
Array.isArray(content) ? content.join("\n") : content
364364
)
365365
)
366366
.then((entry) =>

0 commit comments

Comments
 (0)