diff --git a/CHANGELOG.md b/CHANGELOG.md index f1665de23..c5816fe0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 1.17 +Features: + +- Update `api.ts` to add the `getActiveFolderPath` method. [#3528](https://github.com/microsoft/vscode-cmake-tools/pull/3528) [@Kemaweyan](https://github.com/Kemaweyan) + Improvements: - Improve when the "Configure with Debugger" popup appears and allow for "Do Not Show Again". [#3343](https://github.com/microsoft/vscode-cmake-tools/issues/3343) diff --git a/package.json b/package.json index 039deb566..9cccfbdb5 100644 --- a/package.json +++ b/package.json @@ -3045,7 +3045,7 @@ "tslint": "^6.1.3", "typescript": "^4.1.5", "vsce": "^2.7.0", - "vscode-cmake-tools": "^1.0.0", + "vscode-cmake-tools": "^1.1.0", "vscode-nls-dev": "^3.3.2", "webpack": "^5.76.0", "webpack-cli": "^4.5.0" diff --git a/src/api.ts b/src/api.ts index 3d7579e65..d5da6d0cf 100644 --- a/src/api.ts +++ b/src/api.ts @@ -12,7 +12,7 @@ import { assertNever } from '@cmt/util'; export class CMakeToolsApiImpl implements api.CMakeToolsApi { constructor(private readonly manager: ExtensionManager) {} - version: api.Version = api.Version.v1; + version: api.Version = api.Version.v2; showUIElement(element: api.UIElement): Promise { return this.setUIElementVisibility(element, true); @@ -39,6 +39,10 @@ export class CMakeToolsApiImpl implements api.CMakeToolsApi { return project ? new CMakeProjectWrapper(project) : undefined; } + getActiveFolderPath(): string { + return this.manager.activeFolderPath(); + } + private async setUIElementVisibility(element: api.UIElement, visible: boolean): Promise { switch (element) { case api.UIElement.StatusBarDebugButton: diff --git a/src/extension.ts b/src/extension.ts index d2ae776aa..93b0f9966 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1967,7 +1967,14 @@ async function setup(context: vscode.ExtensionContext, progress?: ProgressHandle vscode.commands.registerCommand('cmake.statusbar.update', () => extensionManager?.updateStatusBarForActiveProjectChange()) ]); - return { getApi: (_version) => ext.api }; + return { getApi: (version: api.Version) => { + // Since our API is backwards compatible, we can make our version number match that which was requested. + if (version === api.Version.v1 || version === api.Version.v2) { + ext.api.version = version; + } + return ext.api; + } + }; } class SchemaProvider implements vscode.TextDocumentContentProvider { diff --git a/yarn.lock b/yarn.lock index 9e8701ff1..a0bf48a23 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6589,10 +6589,10 @@ vsce@^2.7.0: yauzl "^2.3.1" yazl "^2.2.2" -vscode-cmake-tools@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/vscode-cmake-tools/-/vscode-cmake-tools-1.0.0.tgz#0321a74cd073c858c440b01602e164ecb824bd98" - integrity sha512-oZO+Ulo+OGaFuGQaPlNh+qDUWth0kmyz0d45Ws6KmqLGf1Q9gCOBct6jz7mAtzR/IqrCe/VV3O/CUmHfXpIZEA== +vscode-cmake-tools@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/vscode-cmake-tools/-/vscode-cmake-tools-1.1.0.tgz#415da0e18e7dc08500a0e748708290efdbb19485" + integrity sha512-LVOSGrY2aHZBYg0t8mbcAtoYLR+xP4FaXiUx2lNmpK6bs+mK7FA15LgGrjUvgOo34UL5av3ZuAsJ7SROKUDGug== vscode-cpptools@^6.1.0: version "6.1.0"