From 71e8aaea28d2d9d90b711352a4e242e42c35df42 Mon Sep 17 00:00:00 2001 From: Damir Shamanaev Date: Fri, 27 Dec 2024 16:10:38 +0300 Subject: [PATCH] adds fallback for when there's no workspace for a file --- .../tooling/prettier-extension/src/extension.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/external-crates/move/tooling/prettier-extension/src/extension.js b/external-crates/move/tooling/prettier-extension/src/extension.js index a43b827f2eb86..fd3f931baae6c 100644 --- a/external-crates/move/tooling/prettier-extension/src/extension.js +++ b/external-crates/move/tooling/prettier-extension/src/extension.js @@ -76,7 +76,20 @@ function activate(context) { * - Prettier extension settings */ async function findMatchingConfig(documentUri) { - const root = vscode.workspace.getWorkspaceFolder(documentUri).uri.path; + const workspaceFolder = vscode.workspace.getWorkspaceFolder(documentUri); + if (!workspaceFolder) { + const formatterConfig = vscode.workspace.getConfiguration(EXTENSION_NAME); + return { + tabWidth: formatterConfig.get('tabWidth'), + printWidth: formatterConfig.get('printWidth'), + wrapComments: formatterConfig.get('wrapComments'), + useModuleLabel: formatterConfig.get('useModuleLabel'), + autoGroupImports: formatterConfig.get('autoGroupImports'), + enableErrorDebug: formatterConfig.get('errorDebugMode'), + }; + } + + const root = workspaceFolder.uri.path; let lookup = documentUri.path; let search = {};