diff --git a/src/sql/parts/profiler/contrib/profilerActions.contribution.ts b/src/sql/parts/profiler/contrib/profilerActions.contribution.ts index 2e7ce2a69c..6c7070f0d3 100644 --- a/src/sql/parts/profiler/contrib/profilerActions.contribution.ts +++ b/src/sql/parts/profiler/contrib/profilerActions.contribution.ts @@ -55,13 +55,17 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'profiler.newProfiler', weight: KeybindingsRegistry.WEIGHT.builtinExtension(), when: undefined, - primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_P, - mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_P }, + primary: KeyMod.Alt | KeyCode.KEY_P, + mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.KEY_P }, handler: CommandsRegistry.getCommand('profiler.newProfiler').handler }); -CommandsRegistry.registerCommand({ - id: 'profiler.start', +KeybindingsRegistry.registerCommandAndKeybindingRule({ + id: 'profiler.toggleStartStop', + weight: KeybindingsRegistry.WEIGHT.editorContrib(), + when: undefined, + primary: KeyMod.Alt | KeyCode.KEY_S, + mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.KEY_S }, handler: (accessor: ServicesAccessor) => { let profilerService: IProfilerService = accessor.get(IProfilerService); let editorService: IWorkbenchEditorService = accessor.get(IWorkbenchEditorService); @@ -69,23 +73,14 @@ CommandsRegistry.registerCommand({ let activeEditor = editorService.getActiveEditor(); if (activeEditor instanceof ProfilerEditor) { let profilerInput = activeEditor.input; - return profilerService.startSession(profilerInput.id); + if (profilerInput.state.isRunning){ + return profilerService.stopSession(profilerInput.id); + } else { + // clear data when profiler is started + profilerInput.data.clear(); + return profilerService.startSession(profilerInput.id); + } } return TPromise.as(false); } }); - -CommandsRegistry.registerCommand({ - id: 'profiler.stop', - handler: (accessor: ServicesAccessor) => { - let profilerService: IProfilerService = accessor.get(IProfilerService); - let editorService: IWorkbenchEditorService = accessor.get(IWorkbenchEditorService); - - let activeEditor = editorService.getActiveEditor(); - if (activeEditor instanceof ProfilerEditor) { - let profilerInput = activeEditor.input; - return profilerService.stopSession(profilerInput.id); - } - return TPromise.as(false); - } -}); \ No newline at end of file