Skip to content

Commit a9a37a9

Browse files
committed
polish: use a better icon for split/collapse charts
Fixes microsoft/vscode#107837
1 parent ed1d562 commit a9a37a9

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

packages/vscode-js-profile-flame/package.json

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,30 @@
5555
"group": "navigation@1"
5656
},
5757
{
58-
"command": "vscode-js-profile-flame.toggleSplitCharts",
59-
"when": "view == vscode-js-profile-flame.realtime",
58+
"command": "vscode-js-profile-flame.collapseCharts",
59+
"when": "view == vscode-js-profile-flame.realtime && vscodeJsProfileFlameSplitCharts",
60+
"group": "navigation@1"
61+
},
62+
{
63+
"command": "vscode-js-profile-flame.splitCharts",
64+
"when": "view == vscode-js-profile-flame.realtime && !vscodeJsProfileFlameSplitCharts",
6065
"group": "navigation@1"
6166
},
6267
{
6368
"command": "extension.pwa-node-debug.startProfile",
6469
"when": "view == vscode-js-profile-flame.realtime",
6570
"group": "navigation@1"
6671
}
72+
],
73+
"commandPalette": [
74+
{
75+
"command": "vscode-js-profile-flame.collapseCharts",
76+
"when": "debugType =~ /^pwa-/ && vscodeJsProfileFlameSplitCharts"
77+
},
78+
{
79+
"command": "vscode-js-profile-flame.splitCharts",
80+
"when": "debugType =~ /^pwa-/ && !vscodeJsProfileFlameSplitCharts"
81+
}
6782
]
6883
},
6984
"commands": [
@@ -74,10 +89,16 @@
7489
"icon": "$(gear)"
7590
},
7691
{
77-
"command": "vscode-js-profile-flame.toggleSplitCharts",
92+
"command": "vscode-js-profile-flame.collapseCharts",
93+
"category": "Debug",
94+
"title": "Collapse to Realtime Metrics Single Chart",
95+
"icon": "$(collapse-all)"
96+
},
97+
{
98+
"command": "vscode-js-profile-flame.splitCharts",
7899
"category": "Debug",
79-
"title": "Toggle Realtime Split Charts",
80-
"icon": "$(split-vertical)"
100+
"title": "Split Realtime Metrics to Separate Charts",
101+
"icon": "$(expand-all)"
81102
}
82103
],
83104
"configuration": [

packages/vscode-js-profile-flame/src/extension.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ export function activate(context: vscode.ExtensionContext) {
7676
}
7777
}),
7878

79-
vscode.commands.registerCommand('vscode-js-profile-flame.toggleSplitCharts', () => {
80-
const settings = readRealtimeSettings(context);
81-
realtimeTracker.setSplitCharts(!settings.splitCharts);
79+
vscode.commands.registerCommand('vscode-js-profile-flame.splitCharts', () => {
80+
realtimeTracker.setSplitCharts(true);
81+
}),
82+
83+
vscode.commands.registerCommand('vscode-js-profile-flame.collapseCharts', () => {
84+
realtimeTracker.setSplitCharts(false);
8285
}),
8386
);
8487
}

packages/vscode-js-profile-flame/src/realtimeSessionTracker.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ export class RealtimeSessionTracker {
5656
return this.displayedSession && this.sessionData.get(this.displayedSession)?.metrics;
5757
}
5858

59-
constructor(private readonly context: vscode.ExtensionContext) {}
59+
constructor(private readonly context: vscode.ExtensionContext) {
60+
vscode.commands.executeCommand(
61+
'setContext',
62+
'vscodeJsProfileFlameSplitCharts',
63+
readRealtimeSettings(context).splitCharts,
64+
);
65+
}
6066

6167
/**
6268
* Updates the metrics enabled in the displayed chart.
@@ -71,6 +77,7 @@ export class RealtimeSessionTracker {
7177
* different charts.
7278
*/
7379
public setSplitCharts(split: boolean) {
80+
vscode.commands.executeCommand('setContext', 'vscodeJsProfileFlameSplitCharts', split);
7481
this.context.workspaceState.update(splitChartsKey, split);
7582
this.updateSettings();
7683
}

0 commit comments

Comments
 (0)