Skip to content

Commit fd8c3b4

Browse files
committed
review comments
1 parent 819a138 commit fd8c3b4

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@
484484
},
485485
{
486486
"command": "vscode-cmsis-debugger.liveWatch.setValue",
487-
"when": "view == cmsis-debugger.liveWatch",
487+
"when": "view == cmsis-debugger.liveWatch && inDebugMode",
488488
"group": "contextMenuG1@5"
489489
},
490490
{

src/views/live-watch/live-watch.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,14 @@ describe('LiveWatchTreeDataProvider', () => {
271271
expect(refreshSpy).toHaveBeenCalled();
272272
});
273273

274+
it('should show error message when trying to set value with no active session', async () => {
275+
const node = makeNode('node', { result: '1', variablesReference: 0 }, 1);
276+
(liveWatchTreeDataProvider as any)._activeSession = undefined;
277+
const showErrorMessageSpy = jest.spyOn(vscode.window, 'showErrorMessage').mockImplementation(undefined);
278+
await (liveWatchTreeDataProvider as any).handleSetValueCommand(node);
279+
expect(showErrorMessageSpy).toHaveBeenCalledWith('No active debug session');
280+
});
281+
274282
it('AddFromSelection adds selected text as new live watch expression to roots', async () => {
275283
jest.spyOn(liveWatchTreeDataProvider as any, 'evaluate').mockResolvedValue({ result: '5678', variablesReference: 0 });
276284
// Mock the active text editor with fake range
@@ -507,7 +515,7 @@ describe('LiveWatchTreeDataProvider', () => {
507515
const handler = getRegisteredHandler('vscode-cmsis-debugger.liveWatch.setValue');
508516
expect(handler).toBeDefined();
509517
await handler(undefined);
510-
expect(handleSetValueSpy).not.toHaveBeenCalled();
518+
expect(handleSetValueSpy).toHaveBeenCalled();
511519
});
512520

513521
it('set value command does nothing when no new value provided', async () => {
@@ -518,7 +526,7 @@ describe('LiveWatchTreeDataProvider', () => {
518526
const handler = getRegisteredHandler('vscode-cmsis-debugger.liveWatch.setValue');
519527
expect(handler).toBeDefined();
520528
await handler(node);
521-
expect(handleSetValueSpy).not.toHaveBeenCalled();
529+
expect(handleSetValueSpy).toHaveBeenCalled();
522530
});
523531

524532
it('showInMemoryInspector command does nothing when node is undefined', async () => {

src/views/live-watch/live-watch.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ export class LiveWatchTreeDataProvider implements vscode.TreeDataProvider<LiveWa
292292
if (!node) {
293293
return;
294294
}
295+
if (!this._activeSession) {
296+
vscode.window.showErrorMessage('No active debug session');
297+
return;
298+
}
295299
const newValue = await vscode.window.showInputBox({ prompt: 'New Value', value: node.value.result });
296300
if (newValue === undefined) {
297301
return;
@@ -311,7 +315,7 @@ export class LiveWatchTreeDataProvider implements vscode.TreeDataProvider<LiveWa
311315
frameId: frameId
312316
});
313317
}
314-
this.refresh();
318+
await this.refresh();
315319
}
316320

317321
private async addToRoots(expression: string, parent?: LiveWatchNode) {

0 commit comments

Comments
 (0)