Skip to content

Commit 9aa36f2

Browse files
committed
clear highlights when shutting down a debug session
1 parent b5f72ad commit 9aa36f2

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,23 @@ describe('LiveWatchTreeDataProvider', () => {
112112
expect(saveSpy).toHaveBeenCalled();
113113
});
114114

115+
it('clears highlighted labels before saving on session stop', async () => {
116+
await liveWatchTreeDataProvider.activate(tracker);
117+
// Activate session and set up nodes with highlights
118+
(tracker as any)._onDidChangeActiveDebugSession.fire(gdbtargetDebugSession);
119+
const node = makeNode('myVar', {
120+
result: 'value',
121+
variablesReference: 0,
122+
highlightedLabel: { label: 'myVar = ', highlights: [[0, 5]] }
123+
}, 1);
124+
(liveWatchTreeDataProvider as any).roots = [node];
125+
// Stop session triggers save
126+
(tracker as any)._onWillStopSession.fire(gdbtargetDebugSession);
127+
// Allow async handlers to complete
128+
await new Promise(resolve => setTimeout(resolve, 0));
129+
expect(node.value.highlightedLabel).toEqual({ label: 'myVar = ' });
130+
});
131+
115132
it('reassigns IDs sequentially for restored nodes on construction', () => {
116133
const storedNodes = [
117134
{ id: 5, expression: 'expression1', value: 'some-value', parent: undefined },

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ export class LiveWatchTreeDataProvider implements vscode.TreeDataProvider<LiveWa
358358
}
359359

360360
private async save() {
361+
// Clear highlighted labels before saving, as they are only relevant for the current state of the tree and can cause confusion when reloading
362+
for (const node of this.roots) {
363+
node.value.highlightedLabel = { label: node.expression + ' = ' };
364+
}
361365
await this.context.workspaceState.update(this.STORAGE_KEY, this.roots);
362366
}
363367
}

0 commit comments

Comments
 (0)