fix: filesize calculation

This commit is contained in:
iCrawl 2021-02-15 11:06:12 +01:00
parent b55656a014
commit f276c4ad3d
No known key found for this signature in database
GPG key ID: 1AB888B16355FBB2

View file

@ -185,7 +185,12 @@ async function fileDetails(_raw: string, document: TextDocument, selection: Sele
if (raw.includes(REPLACE_KEYS.FileSize)) { if (raw.includes(REPLACE_KEYS.FileSize)) {
let currentDivision = 0; let currentDivision = 0;
let { size } = await workspace.fs.stat(document.uri); let size: number;
try {
({ size } = await workspace.fs.stat(document.uri));
} catch {
size = document.getText().length;
}
const originalSize = size; const originalSize = size;
if (originalSize > 1000) { if (originalSize > 1000) {
size /= 1000; size /= 1000;