Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open figures via the context menu #157

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
- Enabled users to open MATLAB .fig files through the context menu
dklilley marked this conversation as resolved.
Show resolved Hide resolved

### Added
- Enabled users to specify workspace-specific MATLAB install paths

Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -123,6 +127,10 @@
{
"command": "matlab.changeDirectory",
"when": "explorerResourceIsFolder"
},
{
"command": "matlab.openFigure",
"when": "resourceExtname == .fig"
}
]
},
Expand Down
25 changes: 25 additions & 0 deletions src/commandwindow/ExecutionCommandProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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]);
}
}
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export async function activate (context: vscode.ExtensionContext): Promise<void>
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)
Expand Down