diff --git a/CHANGELOG.md b/CHANGELOG.md index a0d3d69..7d83f08 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 +- Open non-code MATLAB files (e.g. `.slx`, `.fig`) via the context menu + ## [1.2.7] - 2024-11-07 ### Added diff --git a/package.json b/package.json index f6ae68a..532e8f9 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,10 @@ "command": "matlab.enableSignIn", "title": "MATLAB: Manage Sign In Options" }, + { + "command": "matlab.openFile", + "title": "MATLAB: Open File" + }, { "command": "matlab.resetDeprecationPopups", "title": "MATLAB: Reset Deprecation Warning Popups" @@ -135,6 +139,11 @@ { "command": "matlab.changeDirectory", "when": "explorerResourceIsFolder" + }, + { + "command": "matlab.openFile", + "when": "!explorerResourceIsFolder", + "group": "files" } ], "matlab.addPath": [ diff --git a/server b/server index c98bd0d..bf34646 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit c98bd0dd23ae12ff29152030d7790e7b8e86fc61 +Subproject commit bf34646e9afbb21a45db1977c23eaa7a768ecd76 diff --git a/src/commandwindow/ExecutionCommandProvider.ts b/src/commandwindow/ExecutionCommandProvider.ts index 794dcce..b5e5ebd 100644 --- a/src/commandwindow/ExecutionCommandProvider.ts +++ b/src/commandwindow/ExecutionCommandProvider.ts @@ -297,4 +297,29 @@ export default class ExecutionCommandProvider { void this._mvm.feval('cd', 0, [uri.fsPath]); } + + /** + * Implements the open file action + * @param uri The file path to the file that should be opened + * @returns + */ + async handleOpenFile (uri: vscode.Uri): Promise { + this._telemetryLogger.logEvent({ + eventKey: 'ML_VS_CODE_ACTIONS', + data: { + action_type: 'openFile', + result: '' + } + }); + + await this._terminalService.openTerminalOrBringToFront(); + + try { + await this._mvm.getReadyPromise(); + } catch (e) { + return; + } + + void this._mvm.feval('open', 0, [uri.fsPath]); + } } diff --git a/src/extension.ts b/src/extension.ts index 9733141..0e5670e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -129,6 +129,7 @@ export async function activate (context: vscode.ExtensionContext): Promise context.subscriptions.push(vscode.commands.registerCommand('matlab.addFolderToPath', async (uri: vscode.Uri) => await executionCommandProvider.handleAddFolderToPath(uri))) context.subscriptions.push(vscode.commands.registerCommand('matlab.addFolderAndSubfoldersToPath', async (uri: vscode.Uri) => await executionCommandProvider.handleAddFolderAndSubfoldersToPath(uri))) context.subscriptions.push(vscode.commands.registerCommand('matlab.changeDirectory', async (uri: vscode.Uri) => await executionCommandProvider.handleChangeDirectory(uri))) + context.subscriptions.push(vscode.commands.registerCommand('matlab.openFile', async (uri: vscode.Uri) => await executionCommandProvider.handleOpenFile(uri))) // Register a custom command which allows the user enable / disable Sign In options. // Using this custom command would be an alternative approach to going to enabling the setting.