Skip to content

Commit

Permalink
feat: add button in debug toolbar to stop profiling
Browse files Browse the repository at this point in the history
Related: microsoft#388
  • Loading branch information
connor4312 committed Mar 27, 2020
1 parent 254c5b1 commit 7af4833
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions demos/node/vscode-js-profile-d82d7c73.cpuprofile

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,14 @@
{
"command": "extension.NAMESPACE(node-debug).startProfile",
"title": "%profile.start%",
"category": "Debug"
"category": "Debug",
"icon": "$(circle-outline)"
},
{
"command": "extension.NAMESPACE(node-debug).stopProfile",
"title": "%profile.stop%",
"category": "Debug"
"category": "Debug",
"icon": "resources/dark/stop-profiling.svg"
}
],
"menus": {
Expand Down Expand Up @@ -276,8 +278,19 @@
},
{
"command": "extension.NAMESPACE(node-debug).startProfile",
"icon": "watch",
"group": "navigation"
"group": "navigation",
"when": "debugType == NAMESPACE(chrome) && !jsDebugIsProfiling"
},
{
"command": "extension.NAMESPACE(node-debug).stopProfile",
"group": "navigation",
"when": "debugType == NAMESPACE(chrome) && jsDebugIsProfiling"
}
],
"debug/toolBar": [
{
"command": "extension.NAMESPACE(node-debug).stopProfile",
"when": "debugType == NAMESPACE(chrome) && jsDebugIsProfiling"
}
],
"view/title": [
Expand Down
2 changes: 1 addition & 1 deletion resources/dark/pause.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions resources/dark/stop-profiling.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/ui/profiling/uiProfileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class UiProfileManager implements IDisposable {
private updateStatusBar() {
if (this.activeSessions.size === 0) {
this.statusBarItem?.hide();
vscode.commands.executeCommand('setContext', 'jsDebugIsProfiling', false);
return;
}

Expand All @@ -135,6 +136,8 @@ export class UiProfileManager implements IDisposable {
this.statusBarItem.command = Contributions.StopProfileCommand;
}

vscode.commands.executeCommand('setContext', 'jsDebugIsProfiling', true);

if (this.activeSessions.size === 1) {
const session: UiProfileSession = this.activeSessions.values().next().value;
this.statusBarItem.text = session.status
Expand Down

0 comments on commit 7af4833

Please sign in to comment.