From f276c4ad3d6b5d9ed430aab2b45098d28995b969 Mon Sep 17 00:00:00 2001 From: iCrawl Date: Mon, 15 Feb 2021 11:06:12 +0100 Subject: [PATCH] fix: filesize calculation --- src/activity.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/activity.ts b/src/activity.ts index 172377c..af18364 100644 --- a/src/activity.ts +++ b/src/activity.ts @@ -185,7 +185,12 @@ async function fileDetails(_raw: string, document: TextDocument, selection: Sele if (raw.includes(REPLACE_KEYS.FileSize)) { 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; if (originalSize > 1000) { size /= 1000;