From d417fd65f240c6ec641e514667aec5828adb2957 Mon Sep 17 00:00:00 2001 From: Devon Friend Date: Fri, 21 Jun 2024 23:46:40 -0700 Subject: [PATCH 1/3] Implement the openFigure command and add to context menu for .fig files --- package.json | 8 ++++++ src/commandwindow/ExecutionCommandProvider.ts | 25 +++++++++++++++++++ src/extension.ts | 1 + 3 files changed, 34 insertions(+) diff --git a/package.json b/package.json index 07110f4..d60a40d 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,10 @@ "command": "matlab.changeDirectory", "title": "MATLAB: Change current directory" }, + { + "command": "matlab.openFigure", + "title": "MATLAB: Open Figure" + }, { "command": "matlab.resetDeprecationPopups", "title": "MATLAB: Reset Deprecation Warning Popups" @@ -123,6 +127,10 @@ { "command": "matlab.changeDirectory", "when": "explorerResourceIsFolder" + }, + { + "command": "matlab.openFigure", + "when": "resourceExtname == .fig" } ] }, diff --git a/src/commandwindow/ExecutionCommandProvider.ts b/src/commandwindow/ExecutionCommandProvider.ts index 44b4748..8b50650 100644 --- a/src/commandwindow/ExecutionCommandProvider.ts +++ b/src/commandwindow/ExecutionCommandProvider.ts @@ -273,4 +273,29 @@ export default class ExecutionCommandProvider { void this._mvm.feval('cd', 0, [uri.fsPath]); } + + /** + * Implements the open figure action + * @param uri The file path to the figure that MATLAB should open + * @returns + */ + async handleOpenFigure(uri: vscode.Uri): Promise { + this._telemetryLogger.logEvent({ + eventKey: 'ML_VS_CODE_ACTIONS', + data: { + action_type: 'openFigure', + result: '' + } + }); + + await this._terminalService.openTerminalOrBringToFront(); + + try { + await this._mvm.getReadyPromise(); + } catch (e) { + return; + } + + void this._mvm.feval('openfig', 0, [uri.fsPath]); + } } diff --git a/src/extension.ts b/src/extension.ts index 6a8e305..24e8906 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -113,6 +113,7 @@ export async function activate (context: vscode.ExtensionContext): Promise context.subscriptions.push(vscode.commands.registerCommand('matlab.openCommandWindow', async () => await terminalService.openTerminalOrBringToFront())) context.subscriptions.push(vscode.commands.registerCommand('matlab.addToPath', async (uri: vscode.Uri) => await executionCommandProvider.handleAddToPath(uri))) context.subscriptions.push(vscode.commands.registerCommand('matlab.changeDirectory', async (uri: vscode.Uri) => await executionCommandProvider.handleChangeDirectory(uri))) + context.subscriptions.push(vscode.commands.registerCommand('matlab.openFigure', async (uri: vscode.Uri) => await executionCommandProvider.handleOpenFigure(uri))) deprecationPopupService = new DeprecationPopupService(context) deprecationPopupService.initialize(client) From b09d2112624fcd77d5113c37e59c8fb284299eda Mon Sep 17 00:00:00 2001 From: Devon Friend Date: Tue, 2 Jul 2024 10:01:21 -0700 Subject: [PATCH 2/3] Add latest changes to the changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb658e7..e62f815 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Enabled users to open MATLAB .fig files through the context menu + ### Added - Enabled users to specify workspace-specific MATLAB install paths From cab2fa2823d98e73da5b1f75789393ba56b89914 Mon Sep 17 00:00:00 2001 From: Devon Friend Date: Tue, 2 Jul 2024 10:06:22 -0700 Subject: [PATCH 3/3] Move latest changelog item under a common Added header --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e62f815..3635ea4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Enabled users to open MATLAB .fig files through the context menu - -### Added - Enabled users to specify workspace-specific MATLAB install paths ### Fixed