From c0f30f2f9b99398f4e99ab4f5d768b14285f63d6 Mon Sep 17 00:00:00 2001 From: waldo Date: Mon, 5 Dec 2022 16:09:52 +0100 Subject: [PATCH] fixed getting settings from AppSourceCop --- CHANGELOG.md | 2 +- package.json | 2 +- src/Settings.ts | 28 ++++++++++++++++++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d172496..93d8d3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Change Log All notable changes to the "crs-al-language-extension" extension: -## [1.5.21] - 2022-12-05 +## [1.5.22] - 2022-12-05 - Snippet contribution from [christianbraeunlich](https://github.com/christianbraeunlich). Thanks! - Support for multiple affixes by [pri-kise](https://github.com/pri-kise). Thanks for [the PR](https://github.com/waldo1001/crs-al-language-extension/pull/254)! diff --git a/package.json b/package.json index 37159ac..8f2661b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "crs-al-language-extension", "displayName": "waldo's CRS AL Language Extension", "description": "Make working with the (Dynamics NAV / 365) AL Language easier and more efficient.", - "version": "1.5.21", + "version": "1.5.22", "publisher": "waldo", "icon": "images/waldo.png", "author": { diff --git a/src/Settings.ts b/src/Settings.ts index b50c0ed..656ac9d 100644 --- a/src/Settings.ts +++ b/src/Settings.ts @@ -150,14 +150,30 @@ export class Settings { } private static getAppSourceCopSettings(ResourceUri: vscode.Uri) { - let appSourceCopSettings = ResourceUri ? - require(join(vscode.workspace.getWorkspaceFolder(ResourceUri).uri.fsPath, "AppSourceCop.json")) : - vscode.window.activeTextEditor ? - require(join(vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).uri.fsPath, "AppSourceCop.json")) : - vscode.workspace.workspaceFolders ? - require(join(vscode.workspace.workspaceFolders[0].uri.fsPath, "AppSourceCop.json")): null; + // let appSourceCopSettings = ResourceUri ? + // require(join(vscode.workspace.getWorkspaceFolder(ResourceUri).uri.fsPath, "AppSourceCop.json")) : + // vscode.window.activeTextEditor ? + // require(join(vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).uri.fsPath, "AppSourceCop.json")) : + // vscode.workspace.workspaceFolders ? + // require(join(vscode.workspace.workspaceFolders[0].uri.fsPath, "AppSourceCop.json")): null; + + let appSourceCopSettings; + + try { + appSourceCopSettings = ResourceUri ? + require(join(vscode.workspace.getWorkspaceFolder(ResourceUri).uri.fsPath, "AppSourceCop.json")) : + vscode.window.activeTextEditor ? + require(join(vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).uri.fsPath, "AppSourceCop.json")) : + vscode.workspace.workspaceFolders ? + require(join(vscode.workspace.workspaceFolders[0].uri.fsPath, "AppSourceCop.json")) : null; + } catch { + appSourceCopSettings = null; + } + if (appSourceCopSettings) { this.SettingCollection[this.MandatoryAffixes] = appSourceCopSettings.mandatoryAffixes + } else { + this.SettingCollection[this.MandatoryAffixes] = null } }