Skip to content

Commit 7facf3d

Browse files
authored
Merge pull request #173 from mathworks/dklilley.release-1.2.5
MATLAB extension for VS Code - v1.2.5
2 parents 89492ef + ec6897e commit 7facf3d

File tree

8 files changed

+139
-43
lines changed

8 files changed

+139
-43
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.2.5] - 2024-08-16
11+
12+
### Added
13+
- Symbol rename support
14+
- Enables users to hide "feature not available" error popups
15+
- Provides context menu option to add selected folder and subfolders to the path
16+
17+
### Fixed
18+
- Leading or trailing whitespace in `installPath` setting is ignored when connecting to MATLAB
19+
1020
## [1.2.4] - 2024-07-12
1121

1222
### Added

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Edit MATLAB code with syntax highlighting, linting, navigation support, and more",
55
"icon": "public/L-Membrane_RGB_128x128.png",
66
"license": "MIT",
7-
"version": "1.2.4",
7+
"version": "1.2.5",
88
"engines": {
99
"vscode": "^1.67.0"
1010
},
@@ -50,8 +50,12 @@
5050
"title": "MATLAB: Interrupt"
5151
},
5252
{
53-
"command": "matlab.addToPath",
54-
"title": "MATLAB: Add Folder To Path"
53+
"command": "matlab.addFolderToPath",
54+
"title": "Selected Folder"
55+
},
56+
{
57+
"command": "matlab.addFolderAndSubfoldersToPath",
58+
"title": "Selected Folder and Subfolders"
5559
},
5660
{
5761
"command": "matlab.changeDirectory",
@@ -83,7 +87,11 @@
8387
"menus": {
8488
"commandPalette": [
8589
{
86-
"command": "matlab.addToPath",
90+
"command": "matlab.addFolderToPath",
91+
"when": "false"
92+
},
93+
{
94+
"command": "matlab.addFolderAndSubfoldersToPath",
8795
"when": "false"
8896
},
8997
{
@@ -117,15 +125,31 @@
117125
],
118126
"explorer/context": [
119127
{
120-
"command": "matlab.addToPath",
128+
"submenu": "matlab.addPath",
121129
"when": "explorerResourceIsFolder"
122130
},
123131
{
124132
"command": "matlab.changeDirectory",
125133
"when": "explorerResourceIsFolder"
126134
}
135+
],
136+
"matlab.addPath": [
137+
{
138+
"command": "matlab.addFolderToPath",
139+
"when": "explorerResourceIsFolder"
140+
},
141+
{
142+
"command": "matlab.addFolderAndSubfoldersToPath",
143+
"when": "explorerResourceIsFolder"
144+
}
127145
]
128146
},
147+
"submenus": [
148+
{
149+
"id": "matlab.addPath",
150+
"label": "MATLAB: Add to Path"
151+
}
152+
],
129153
"configuration": {
130154
"title": "MATLAB",
131155
"properties": {
@@ -165,6 +189,12 @@
165189
"telemetry",
166190
"usesOnlineServices"
167191
]
192+
},
193+
"MATLAB.showFeatureNotAvailableError": {
194+
"type": "boolean",
195+
"default": true,
196+
"description": "Display an error when a feature requires MATLAB and MATLAB is unable to start.",
197+
"scope": "window"
168198
}
169199
}
170200
},

src/NotificationConstants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ export default {
77
},
88
MATLAB_LAUNCH_FAILED: {
99
message: 'MATLAB was unable to start. If MATLAB is installed, confirm that the MATLAB executable path setting is properly configured.',
10-
options: ['Get MATLAB', 'Open Settings']
10+
options: ['Get MATLAB', 'Open settings', 'Do not show again']
1111
},
1212
FEATURE_UNAVAILABLE: {
1313
message: 'This feature is not available without MATLAB running.',
14-
options: ['Start MATLAB']
14+
options: ['Start MATLAB', 'Do not show again']
1515
},
1616
FEATURE_UNAVAILABLE_NO_MATLAB: {
1717
message: 'This feature is not available without MATLAB installed. If MATLAB is installed, confirm that the MATLAB executable path setting is properly configured.',
18-
options: ['Get MATLAB', 'Open Settings']
18+
options: ['Get MATLAB', 'Open settings', 'Do not show again']
1919
}
2020
}

src/commandwindow/ExecutionCommandProvider.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export default class ExecutionCommandProvider {
229229
* @param uri The file path that should be added to the MATLAB path
230230
* @returns
231231
*/
232-
async handleAddToPath (uri: vscode.Uri): Promise<void> {
232+
async handleAddFolderToPath (uri: vscode.Uri): Promise<void> {
233233
this._telemetryLogger.logEvent({
234234
eventKey: 'ML_VS_CODE_ACTIONS',
235235
data: {
@@ -249,6 +249,30 @@ export default class ExecutionCommandProvider {
249249
void this._mvm.feval('addpath', 0, [uri.fsPath]);
250250
}
251251

252+
async handleAddFolderAndSubfoldersToPath (uri: vscode.Uri): Promise<void> {
253+
this._telemetryLogger.logEvent({
254+
eventKey: 'ML_VS_CODE_ACTIONS',
255+
data: {
256+
action_type: 'addFolderAndSubfoldersToPath',
257+
result: ''
258+
}
259+
});
260+
261+
await this._terminalService.openTerminalOrBringToFront();
262+
263+
try {
264+
await this._mvm.getReadyPromise();
265+
} catch (e) {
266+
return;
267+
}
268+
269+
// Escape any single quotes in the folder's path
270+
const escapedPath = uri.fsPath.replace(/'/g, "''");
271+
272+
const command = `addpath(genpath('${escapedPath}'))`;
273+
void this._mvm.eval(command);
274+
}
275+
252276
/**
253277
* Implements the MATLAB change directory action
254278
* @param uri The file path that MATLAB should "cd" to

src/extension.ts

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ export async function activate (context: vscode.ExtensionContext): Promise<void>
111111
context.subscriptions.push(vscode.commands.registerCommand('matlab.runSelection', async () => await executionCommandProvider.handleRunSelection()))
112112
context.subscriptions.push(vscode.commands.registerCommand('matlab.interrupt', () => executionCommandProvider.handleInterrupt()))
113113
context.subscriptions.push(vscode.commands.registerCommand('matlab.openCommandWindow', async () => await terminalService.openTerminalOrBringToFront()))
114-
context.subscriptions.push(vscode.commands.registerCommand('matlab.addToPath', async (uri: vscode.Uri) => await executionCommandProvider.handleAddToPath(uri)))
114+
context.subscriptions.push(vscode.commands.registerCommand('matlab.addFolderToPath', async (uri: vscode.Uri) => await executionCommandProvider.handleAddFolderToPath(uri)))
115+
context.subscriptions.push(vscode.commands.registerCommand('matlab.addFolderAndSubfoldersToPath', async (uri: vscode.Uri) => await executionCommandProvider.handleAddFolderAndSubfoldersToPath(uri)))
115116
context.subscriptions.push(vscode.commands.registerCommand('matlab.changeDirectory', async (uri: vscode.Uri) => await executionCommandProvider.handleChangeDirectory(uri)))
116117

117118
deprecationPopupService = new DeprecationPopupService(context)
@@ -185,16 +186,26 @@ function handleMatlabLaunchFailed (): void {
185186
const url = 'https://www.mathworks.com/products/get-matlab.html'
186187

187188
terminalService.closeTerminal();
188-
vscode.window.showErrorMessage(message, ...options).then(choice => {
189-
switch (choice) {
190-
case options[0]: // Get MATLAB
191-
void vscode.env.openExternal(vscode.Uri.parse(url))
192-
break
193-
case options[1]: // Open Settings
194-
void vscode.commands.executeCommand(OPEN_SETTINGS_ACTION, MATLAB_INSTALL_PATH_SETTING)
195-
break
196-
}
197-
}, reject => console.error(reject))
189+
190+
const configuration = vscode.workspace.getConfiguration('MATLAB')
191+
const shouldShowPopup = configuration.get<boolean>('showFeatureNotAvailableError') ?? true
192+
193+
if (shouldShowPopup) {
194+
vscode.window.showErrorMessage(message, ...options).then(choice => {
195+
switch (choice) {
196+
case options[0]: // Get MATLAB
197+
void vscode.env.openExternal(vscode.Uri.parse(url))
198+
break
199+
case options[1]: // Open settings
200+
void vscode.commands.executeCommand(OPEN_SETTINGS_ACTION, MATLAB_INSTALL_PATH_SETTING)
201+
break
202+
case options[2]: // Do not show again
203+
// Selected to not show again
204+
void configuration.update('showFeatureNotAvailableError', false, true)
205+
break
206+
}
207+
}, reject => console.error(reject))
208+
}
198209
}
199210

200211
/**
@@ -205,15 +216,27 @@ function handleFeatureUnavailable (): void {
205216
const options = NotificationConstants.FEATURE_UNAVAILABLE.options
206217

207218
terminalService.closeTerminal();
208-
vscode.window.showErrorMessage(
209-
message,
210-
...options
211-
).then(choice => {
212-
if (choice != null) {
213-
// Selected to start MATLAB
214-
sendConnectionActionNotification('connect')
215-
}
216-
}, reject => console.error(reject))
219+
220+
const configuration = vscode.workspace.getConfiguration('MATLAB')
221+
const shouldShowPopup = configuration.get<boolean>('showFeatureNotAvailableError') ?? true
222+
223+
if (shouldShowPopup) {
224+
vscode.window.showErrorMessage(
225+
message,
226+
...options
227+
).then(choice => {
228+
switch (choice) {
229+
case options[0]: // Get MATLAB
230+
// Selected to start MATLAB
231+
sendConnectionActionNotification('connect')
232+
break
233+
case options[1]: // Do not show again
234+
// Selected to not show again
235+
void configuration.update('showFeatureNotAvailableError', false, true)
236+
break
237+
}
238+
}, reject => console.error(reject))
239+
}
217240
}
218241

219242
/**
@@ -226,16 +249,25 @@ function handleFeatureUnavailableWithNoMatlab (): void {
226249
const url = 'https://www.mathworks.com/products/get-matlab.html'
227250

228251
terminalService.closeTerminal();
229-
vscode.window.showErrorMessage(message, ...options).then(choice => {
230-
switch (choice) {
231-
case options[0]: // Get MATLAB
232-
void vscode.env.openExternal(vscode.Uri.parse(url))
233-
break
234-
case options[1]: // Open Settings
235-
void vscode.commands.executeCommand(OPEN_SETTINGS_ACTION, MATLAB_INSTALL_PATH_SETTING)
236-
break
237-
}
238-
}, reject => console.error(reject))
252+
253+
const configuration = vscode.workspace.getConfiguration('MATLAB')
254+
const shouldShowPopup = configuration.get<boolean>('showFeatureNotAvailableError') ?? true
255+
256+
if (shouldShowPopup) {
257+
vscode.window.showErrorMessage(message, ...options).then(choice => {
258+
switch (choice) {
259+
case options[0]: // Get MATLAB
260+
void vscode.env.openExternal(vscode.Uri.parse(url))
261+
break
262+
case options[1]: // Open settings
263+
void vscode.commands.executeCommand(OPEN_SETTINGS_ACTION, MATLAB_INSTALL_PATH_SETTING)
264+
break
265+
case options[2]: // Do not show again
266+
// Selected to not show again
267+
void configuration.update('showFeatureNotAvailableError', false, true)
268+
}
269+
}, reject => console.error(reject))
270+
}
239271
}
240272

241273
function handleTelemetryReceived (event: TelemetryEvent): void {

0 commit comments

Comments
 (0)