diff --git a/CHANGELOG.md b/CHANGELOG.md index 2754c50..08c2220 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log All notable changes to the "crs-al-language-extension" extension: +## [1.5.32] - 2024-07-15 +Made it possible to have multiple extension objects names (thanks for [reporting](https://github.com/waldo1001/crs-al-language-extension/issues/305), [Natalie](https://github.com/NKarolak)). +The way it works: It's regarding setting `ExtensionObjectNamePattern`. +If you, as deverlop, would add extra characters after this pattern, the extension will accept them. For example, if you would have a setting ` Ext`, and you would have an extension object named `MyTable Ext 2`, the extension will accept this as a valid object name and not change it bak to `MyTable Ext`. ## [1.5.31] - 2023-11-27 Fixed snippets (removed ";" after procedure). diff --git a/README.md b/README.md index b47b858..1ec99d0 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ This extension contributes the following settings: * `CRS.WinServerInstance`: Serverinstance where the windows client is connecting to * `CRS.WinServerInstancePort`: Portnumber of the serverinstance where the windows client is connecting to * `CRS.PublicWebBaseUrl`: Override Launch.json settings with this setting if necessary to run objects from VSCode -* `CRS.ExtensionObjectNamePattern`: The pattern for the object name. If set (it's not set by default), it will perform an automatic object name for extension objects +* `CRS.ExtensionObjectNamePattern`: The pattern for the object name. If set (it's not set by default), it will perform an automatic object name for extension objects. To support multiple extensions per app, the system will accept manually added characters at the end of the pattern as well. These vars can be used: - `` - `` - `` diff --git a/package.json b/package.json index 1a1323a..e6da393 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.31", + "version": "1.5.32", "publisher": "waldo", "icon": "images/waldo.png", "author": { @@ -174,7 +174,7 @@ "CRS.ExtensionObjectNamePattern": { "Type": "string", "default": "", - "description": "The pattern of the objectname for extension objects (PageExtension or TableExtension). These vars can be used: ,,,,,,,,,", + "description": "The pattern of the objectname for extension objects. These vars can be used: ,,,,,,,,,. Remark: the system will accept manually added characters following this pattern.", "scope": "resource" }, "CRS.FileNamePattern": { diff --git a/src/NAVObject.ts b/src/NAVObject.ts index 33c6e7c..a3e29c1 100644 --- a/src/NAVObject.ts +++ b/src/NAVObject.ts @@ -74,6 +74,10 @@ export class NAVObject { if (objectNameFixed == this.objectName.trim().toString()) { objectNameFixed = this.AddPrefixAndSuffixToObjectNameFixed(objectNameFixed); } + //Accept original value when characters added to the end of the objectname + if (this.objectName.startsWith(objectNameFixed)) { + objectNameFixed = this.objectName; + } return objectNameFixed; } diff --git a/src/test/suite/NAVObject.FilePattern.test.ts b/src/test/suite/NAVObject.FilePattern.test.ts index 55df5be..dd3aa9d 100644 --- a/src/test/suite/NAVObject.FilePattern.test.ts +++ b/src/test/suite/NAVObject.FilePattern.test.ts @@ -405,6 +405,18 @@ suite("NAVObject FilePattern Tests", () => { + navObject.extendedObjectId) }) + test("TableExtension - Dont Change Name is not necessary", () => { + let testSettings = Settings.GetConfigSettings(null) + testSettings[Settings.ExtensionObjectNamePattern] = ' Ext'; + + let navTestObject = NAVTestObjectLibrary.getTableExtensionWithDecentNameAlready() + let navObject = new NAVObject(navTestObject.ObjectText, testSettings, navTestObject.ObjectFileName) + + assert.strictEqual( + navObject.objectNameFixed, + navObject.objectName) + }) + test("FileName - Extension Object with which would be too", () => { let testSettings = Settings.GetConfigSettings(null) diff --git a/src/test/suite/NAVTestObjectLibrary.ts b/src/test/suite/NAVTestObjectLibrary.ts index be49e32..a28d024 100644 --- a/src/test/suite/NAVTestObjectLibrary.ts +++ b/src/test/suite/NAVTestObjectLibrary.ts @@ -514,6 +514,21 @@ export function getTableExtensionWrongFileNameAndKeyWord(): NAVTestObject { } } +} + ` + return object; +} +export function getTableExtensionWithDecentNameAlready(): NAVTestObject { + let object = new NAVTestObject; + + object.ObjectFileName = 'SomeTableExt.al' + object.ObjectText = `tableextension 50100 "Customer Ext 2" extends Customer //18 +{ + fields + { + + } + } ` return object;