File tree Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased]
99
10+ ### Added
11+ - Open non-code MATLAB files (e.g. ` .slx ` , ` .fig ` ) via the context menu
12+
1013## [ 1.2.7] - 2024-11-07
1114
1215### Added
Original file line number Diff line number Diff line change 132132 },
133133 {
134134 "command" : " matlab.openFile" ,
135- "when" : " editorLangId == matlab && editorHasSelection && resourceExtname != '.m'"
135+ "when" : " editorHasSelection" ,
136+ "group" : " files"
136137 }
137138 ],
138139 "explorer/context" : [
Original file line number Diff line number Diff line change @@ -297,4 +297,29 @@ export default class ExecutionCommandProvider {
297297
298298 void this . _mvm . feval ( 'cd' , 0 , [ uri . fsPath ] ) ;
299299 }
300+
301+ /**
302+ * Implements the open file action
303+ * @param uri The file path to the file that should be opened
304+ * @returns
305+ */
306+ async handleOpenFile ( uri : vscode . Uri ) : Promise < void > {
307+ this . _telemetryLogger . logEvent ( {
308+ eventKey : 'ML_VS_CODE_ACTIONS' ,
309+ data : {
310+ action_type : 'openFile' ,
311+ result : ''
312+ }
313+ } ) ;
314+
315+ await this . _terminalService . openTerminalOrBringToFront ( ) ;
316+
317+ try {
318+ await this . _mvm . getReadyPromise ( ) ;
319+ } catch ( e ) {
320+ return ;
321+ }
322+
323+ void this . _mvm . feval ( 'open' , 0 , [ uri . fsPath ] ) ;
324+ }
300325}
Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ export async function activate (context: vscode.ExtensionContext): Promise<void>
129129 context . subscriptions . push ( vscode . commands . registerCommand ( 'matlab.addFolderToPath' , async ( uri : vscode . Uri ) => await executionCommandProvider . handleAddFolderToPath ( uri ) ) )
130130 context . subscriptions . push ( vscode . commands . registerCommand ( 'matlab.addFolderAndSubfoldersToPath' , async ( uri : vscode . Uri ) => await executionCommandProvider . handleAddFolderAndSubfoldersToPath ( uri ) ) )
131131 context . subscriptions . push ( vscode . commands . registerCommand ( 'matlab.changeDirectory' , async ( uri : vscode . Uri ) => await executionCommandProvider . handleChangeDirectory ( uri ) ) )
132+ context . subscriptions . push ( vscode . commands . registerCommand ( 'matlab.openFile' , async ( uri : vscode . Uri ) => await executionCommandProvider . handleOpenFile ( uri ) ) )
132133
133134 // Register a custom command which allows the user enable / disable Sign In options.
134135 // Using this custom command would be an alternative approach to going to enabling the setting.
You can’t perform that action at this time.
0 commit comments