Skip to content

Commit 15ff8b1

Browse files
committed
fix #394 don't mangle binary files
1 parent 191691d commit 15ff8b1

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
@@ -336,8 +336,8 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
336336
name,
337337
fileName,
338338
ts,
339-
Array.isArray(content) ? content.join("\n").length : String(content).length,
340-
Array.isArray(content) ? content.join("\n") : String(content)
339+
Array.isArray(content) ? content.join("\n").length : content.length,
340+
Array.isArray(content) ? content.join("\n") : content
341341
)
342342
)
343343
.then((entry) =>

0 commit comments

Comments
 (0)