From dc21fe57717f0b73ddaf4c342919a295c66f438c Mon Sep 17 00:00:00 2001 From: "Gusmano.2" Date: Fri, 8 Nov 2024 08:47:26 -0500 Subject: [PATCH 1/7] pull from origin main --- server | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server b/server index c98bd0d..bf34646 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit c98bd0dd23ae12ff29152030d7790e7b8e86fc61 +Subproject commit bf34646e9afbb21a45db1977c23eaa7a768ecd76 From 9534d2724ac32c7047d32773fd95128569b36433 Mon Sep 17 00:00:00 2001 From: "Gusmano.2" Date: Fri, 8 Nov 2024 09:44:29 -0500 Subject: [PATCH 2/7] Add command and menu items --- package.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package.json b/package.json index f6ae68a..804119c 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" @@ -125,6 +129,10 @@ "command": "matlab.runSelection", "when": "editorLangId == matlab && editorHasSelection && !editorHasMultipleSelections", "group": "1_run" + }, + { + "command": "matlab.openFile", + "when": "editorLangId == matlab && editorHasSelection && resourceExtname != '.m'" } ], "explorer/context": [ From 3f65160405e496c401777df7370f82d683c41c11 Mon Sep 17 00:00:00 2001 From: "Gusmano.2" Date: Fri, 8 Nov 2024 12:07:45 -0500 Subject: [PATCH 3/7] Implement openFile command --- CHANGELOG.md | 3 +++ package.json | 3 ++- src/commandwindow/ExecutionCommandProvider.ts | 25 +++++++++++++++++++ src/extension.ts | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) 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 804119c..7da0c9f 100644 --- a/package.json +++ b/package.json @@ -132,7 +132,8 @@ }, { "command": "matlab.openFile", - "when": "editorLangId == matlab && editorHasSelection && resourceExtname != '.m'" + "when": "editorHasSelection", + "group": "files" } ], "explorer/context": [ diff --git a/src/commandwindow/ExecutionCommandProvider.ts b/src/commandwindow/ExecutionCommandProvider.ts index 794dcce..0de7b00 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. From 7c69553eb3665b642ba1f804658415300a2dce61 Mon Sep 17 00:00:00 2001 From: "Gusmano.2" Date: Mon, 18 Nov 2024 15:18:11 -0500 Subject: [PATCH 4/7] Fix implementation of command in explorer context menu --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 7da0c9f..532e8f9 100644 --- a/package.json +++ b/package.json @@ -129,11 +129,6 @@ "command": "matlab.runSelection", "when": "editorLangId == matlab && editorHasSelection && !editorHasMultipleSelections", "group": "1_run" - }, - { - "command": "matlab.openFile", - "when": "editorHasSelection", - "group": "files" } ], "explorer/context": [ @@ -144,6 +139,11 @@ { "command": "matlab.changeDirectory", "when": "explorerResourceIsFolder" + }, + { + "command": "matlab.openFile", + "when": "!explorerResourceIsFolder", + "group": "files" } ], "matlab.addPath": [ From 0d7d2023b4a8245be26455e169065de56946c877 Mon Sep 17 00:00:00 2001 From: "Gusmano.2" Date: Mon, 18 Nov 2024 16:26:11 -0500 Subject: [PATCH 5/7] Begin implementation of opening multiple files at once. --- src/commandwindow/ExecutionCommandProvider.ts | 8 +++++--- src/extension.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/commandwindow/ExecutionCommandProvider.ts b/src/commandwindow/ExecutionCommandProvider.ts index 0de7b00..dd884e6 100644 --- a/src/commandwindow/ExecutionCommandProvider.ts +++ b/src/commandwindow/ExecutionCommandProvider.ts @@ -300,10 +300,10 @@ export default class ExecutionCommandProvider { /** * Implements the open file action - * @param uri The file path to the file that should be opened + * @param uris The file paths to the files that should be opened * @returns */ - async handleOpenFile(uri: vscode.Uri): Promise { + async handleOpenFile (uris: vscode.Uri[]): Promise { this._telemetryLogger.logEvent({ eventKey: 'ML_VS_CODE_ACTIONS', data: { @@ -320,6 +320,8 @@ export default class ExecutionCommandProvider { return; } - void this._mvm.feval('open', 0, [uri.fsPath]); + for (const uri of uris) { + void this._mvm.feval('open', 0, [uri.fsPath]); + } } } diff --git a/src/extension.ts b/src/extension.ts index 0e5670e..bdcd813 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -129,7 +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))) + context.subscriptions.push(vscode.commands.registerCommand('matlab.openFile', async (uris: vscode.Uri[]) => await executionCommandProvider.handleOpenFile(uris))) // 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. From be9af9c25a670a3d2f7923299ed478b7b7907e9f Mon Sep 17 00:00:00 2001 From: "Gusmano.2" Date: Tue, 19 Nov 2024 11:26:56 -0500 Subject: [PATCH 6/7] Revert "Begin implementation of opening multiple files at once." This reverts commit 0d7d2023b4a8245be26455e169065de56946c877. --- src/commandwindow/ExecutionCommandProvider.ts | 8 +++----- src/extension.ts | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/commandwindow/ExecutionCommandProvider.ts b/src/commandwindow/ExecutionCommandProvider.ts index dd884e6..0de7b00 100644 --- a/src/commandwindow/ExecutionCommandProvider.ts +++ b/src/commandwindow/ExecutionCommandProvider.ts @@ -300,10 +300,10 @@ export default class ExecutionCommandProvider { /** * Implements the open file action - * @param uris The file paths to the files that should be opened + * @param uri The file path to the file that should be opened * @returns */ - async handleOpenFile (uris: vscode.Uri[]): Promise { + async handleOpenFile(uri: vscode.Uri): Promise { this._telemetryLogger.logEvent({ eventKey: 'ML_VS_CODE_ACTIONS', data: { @@ -320,8 +320,6 @@ export default class ExecutionCommandProvider { return; } - for (const uri of uris) { - void this._mvm.feval('open', 0, [uri.fsPath]); - } + void this._mvm.feval('open', 0, [uri.fsPath]); } } diff --git a/src/extension.ts b/src/extension.ts index bdcd813..0e5670e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -129,7 +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 (uris: vscode.Uri[]) => await executionCommandProvider.handleOpenFile(uris))) + 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. From f22b1f3054bacef45ec73598e52d37a766744381 Mon Sep 17 00:00:00 2001 From: "Gusmano.2" Date: Tue, 19 Nov 2024 13:22:13 -0500 Subject: [PATCH 7/7] lint fix --- src/commandwindow/ExecutionCommandProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commandwindow/ExecutionCommandProvider.ts b/src/commandwindow/ExecutionCommandProvider.ts index 0de7b00..b5e5ebd 100644 --- a/src/commandwindow/ExecutionCommandProvider.ts +++ b/src/commandwindow/ExecutionCommandProvider.ts @@ -303,7 +303,7 @@ export default class ExecutionCommandProvider { * @param uri The file path to the file that should be opened * @returns */ - async handleOpenFile(uri: vscode.Uri): Promise { + async handleOpenFile (uri: vscode.Uri): Promise { this._telemetryLogger.logEvent({ eventKey: 'ML_VS_CODE_ACTIONS', data: {