Skip to content

Commit

Permalink
Merge pull request #188 from Gusmano-2-OSU/openMatlabFiles
Browse files Browse the repository at this point in the history
Opening figures, simulink models, etc. in VS Code
  • Loading branch information
dklilley authored Dec 3, 2024
2 parents 1046abf + f22b1f3 commit 50dcd07
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -135,6 +139,11 @@
{
"command": "matlab.changeDirectory",
"when": "explorerResourceIsFolder"
},
{
"command": "matlab.openFile",
"when": "!explorerResourceIsFolder",
"group": "files"
}
],
"matlab.addPath": [
Expand Down
2 changes: 1 addition & 1 deletion server
Submodule server updated 107 files
25 changes: 25 additions & 0 deletions src/commandwindow/ExecutionCommandProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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]);
}
}
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export async function activate (context: vscode.ExtensionContext): Promise<void>
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.
Expand Down

0 comments on commit 50dcd07

Please sign in to comment.