From 5113e0cafb5e0b0c6708b04fd8bfee118291daf8 Mon Sep 17 00:00:00 2001 From: Michel Kaporin Date: Mon, 20 Feb 2017 11:57:10 +0100 Subject: [PATCH 1/6] Added debug keyword for quick open menu. --- .../parts/debug/browser/debugQuickOpen.ts | 104 ++++++++++++++++++ .../electron-browser/debug.contribution.ts | 11 ++ 2 files changed, 115 insertions(+) create mode 100644 src/vs/workbench/parts/debug/browser/debugQuickOpen.ts diff --git a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts new file mode 100644 index 0000000000000..4b0c73c2b87e0 --- /dev/null +++ b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts @@ -0,0 +1,104 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import nls = require('vs/nls'); +import Filters = require('vs/base/common/filters'); +import { TPromise } from 'vs/base/common/winjs.base'; +import Quickopen = require('vs/workbench/browser/quickopen'); +import QuickOpen = require('vs/base/parts/quickopen/common/quickOpen'); +import Model = require('vs/base/parts/quickopen/browser/quickOpenModel'); +import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; +import { IDebugService } from 'vs/workbench/parts/debug/common/debug'; +import * as errors from 'vs/base/common/errors'; + +class DebugEntry extends Model.QuickOpenEntry { + private debugService: IDebugService; + private configurationName: string; + + constructor(debugService: IDebugService, config: string, highlights: Model.IHighlight[] = []) { + super(highlights); + this.debugService = debugService; + this.configurationName = config; + } + + public getLabel(): string { + return this.configurationName; + } + + public getAriaLabel(): string { + return nls.localize('entryAriaLabel', "{0}, debug", this.getLabel()); + } + + public run(mode: QuickOpen.Mode, context: Model.IContext): boolean { + if (mode === QuickOpen.Mode.PREVIEW) { + return false; + } + // Run selected debug configuration + this.debugService.createProcess(this.configurationName).done(undefined, errors.onUnexpectedError); + + return true; + } +} + +export class QuickOpenHandler extends Quickopen.QuickOpenHandler { + + private debugService: IDebugService; + private quickOpenService: IQuickOpenService; + + constructor( + @IQuickOpenService quickOpenService: IQuickOpenService, + @IDebugService debugService: IDebugService + ) { + super(); + + this.quickOpenService = quickOpenService; + this.debugService = debugService; + } + + public getAriaLabel(): string { + return nls.localize('debugAriaLabel', "Type the name of a launch configuration to run"); + } + + public getResults(input: string): TPromise { + const configurationNames = this.debugService.getConfigurationManager().getConfigurationNames() + .sort((a, b) => a.localeCompare(b)) + .map(config => ({ config: config, highlights: Filters.matchesContiguousSubString(input, config) })) + .filter(({ highlights }) => !!highlights) + .map(({ config, highlights }) => new DebugEntry(this.debugService, config, highlights)); + + return TPromise.as(new Model.QuickOpenModel(configurationNames)); + } + + public getClass(): string { + return null; + } + + public canRun(): boolean { + return true; + } + + public getAutoFocus(input: string): QuickOpen.IAutoFocus { + return { + autoFocusFirstEntry: !!input + }; + } + + public onClose(cancelled: boolean): void { + return; + } + + public getGroupLabel(): string { + return null; + } + + public getEmptyLabel(searchString: string): string { + if (searchString.length > 0) { + return nls.localize('noConfigurationsMatching', "No debug configurations matching"); + } + + return nls.localize('noConfigurationsFound', "No debug configurations found"); + } +} \ No newline at end of file diff --git a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts index 4e8087d2527ee..1a40433c392b3 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts @@ -34,6 +34,7 @@ import 'vs/workbench/parts/debug/electron-browser/debugEditorContribution'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import * as debugCommands from 'vs/workbench/parts/debug/electron-browser/debugCommands'; +import { IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen'; class OpenDebugViewletAction extends ToggleViewletAction { public static ID = VIEWLET_ID; @@ -128,6 +129,16 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(DisableAllBreakpointsA registry.registerWorkbenchAction(new SyncActionDescriptor(ClearReplAction, ClearReplAction.ID, ClearReplAction.LABEL), 'Debug: Clear Debug Console', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(FocusReplAction, FocusReplAction.ID, FocusReplAction.LABEL), 'Debug: Focus Debug Console', debugCategory); +// Register Quick Open +(Registry.as(QuickOpenExtensions.Quickopen)).registerQuickOpenHandler( + new QuickOpenHandlerDescriptor( + 'vs/workbench/parts/debug/browser/debugQuickOpen', + 'QuickOpenHandler', + 'debug ', + nls.localize('debugCommands', "Debug XXX") + ) +); + // register service registerSingleton(IDebugService, service.DebugService); From a19e72c45553b23c1c43976cc954eb42f80d0f3a Mon Sep 17 00:00:00 2001 From: Michel Kaporin Date: Mon, 20 Feb 2017 13:16:07 +0100 Subject: [PATCH 2/6] Added separate action for the workbench for launching different debug configs. --- .../parts/debug/browser/debugActions.ts | 23 +++++++++++++++++++ .../parts/debug/browser/debugQuickOpen.ts | 1 + .../electron-browser/debug.contribution.ts | 3 ++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index 9b9c420ad9e36..a41b7b6401ceb 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -19,6 +19,7 @@ import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { TogglePanelAction } from 'vs/workbench/browser/panel'; +import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; export abstract class AbstractDebugAction extends Action { @@ -210,6 +211,28 @@ export class RunAction extends StartAction { } } +export class LaunchAction extends RunAction { + private quickOpenService: IQuickOpenService; + static ID = 'workbench.action.debug.launch'; + static LABEL = nls.localize('launchDebugConfiguration', "Select Debug Configuration to Launch"); + + constructor(id: string, label: string, + @IDebugService debugService: IDebugService, + @IKeybindingService keybindingService: IKeybindingService, + @ICommandService commandService: ICommandService, + @IWorkspaceContextService contextService: IWorkspaceContextService, + @IFileService fileService: IFileService, + @IQuickOpenService quickOpenService: IQuickOpenService + ) { + super(id, label, debugService, keybindingService, commandService, contextService, fileService); + this.quickOpenService = quickOpenService; + } + + public run(): TPromise { + return TPromise.as(this.quickOpenService.show('debug ')); + } +} + export class RestartAction extends AbstractDebugAction { static ID = 'workbench.action.debug.restart'; static LABEL = nls.localize('restartDebug', "Restart"); diff --git a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts index 4b0c73c2b87e0..f5bd9c6ae9e0e 100644 --- a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts +++ b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts @@ -38,6 +38,7 @@ class DebugEntry extends Model.QuickOpenEntry { } // Run selected debug configuration this.debugService.createProcess(this.configurationName).done(undefined, errors.onUnexpectedError); + this.debugService.getViewModel().setSelectedConfigurationName(this.configurationName); return true; } diff --git a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts index 1a40433c392b3..d8472888ece64 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts @@ -25,7 +25,7 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { DebugEditorModelManager } from 'vs/workbench/parts/debug/browser/debugEditorModelManager'; import { StepOverAction, ClearReplAction, FocusReplAction, StepIntoAction, StepOutAction, StartAction, RestartAction, ContinueAction, StopAction, DisconnectAction, PauseAction, AddFunctionBreakpointAction, - ConfigureAction, DisableAllBreakpointsAction, EnableAllBreakpointsAction, RemoveAllBreakpointsAction, RunAction, ReapplyBreakpointsAction + ConfigureAction, DisableAllBreakpointsAction, EnableAllBreakpointsAction, RemoveAllBreakpointsAction, RunAction, ReapplyBreakpointsAction, LaunchAction } from 'vs/workbench/parts/debug/browser/debugActions'; import { DebugActionsWidget } from 'vs/workbench/parts/debug/browser/debugActionsWidget'; import * as service from 'vs/workbench/parts/debug/electron-browser/debugService'; @@ -128,6 +128,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(EnableAllBreakpointsAc registry.registerWorkbenchAction(new SyncActionDescriptor(DisableAllBreakpointsAction, DisableAllBreakpointsAction.ID, DisableAllBreakpointsAction.LABEL), 'Debug: Disable All Breakpoints', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(ClearReplAction, ClearReplAction.ID, ClearReplAction.LABEL), 'Debug: Clear Debug Console', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(FocusReplAction, FocusReplAction.ID, FocusReplAction.LABEL), 'Debug: Focus Debug Console', debugCategory); +registry.registerWorkbenchAction(new SyncActionDescriptor(LaunchAction, LaunchAction.ID, LaunchAction.LABEL, null, CONTEXT_NOT_IN_DEBUG_MODE), 'Debug: Launch Configuration', debugCategory); // Register Quick Open (Registry.as(QuickOpenExtensions.Quickopen)).registerQuickOpenHandler( From a369897c247ded816fabfd52db388d52e8006b9a Mon Sep 17 00:00:00 2001 From: Michel Kaporin Date: Tue, 21 Feb 2017 09:53:51 +0100 Subject: [PATCH 3/6] Changed label for the launch action. --- src/vs/workbench/parts/debug/browser/debugActions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index a41b7b6401ceb..b8db1925e41a2 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -214,7 +214,7 @@ export class RunAction extends StartAction { export class LaunchAction extends RunAction { private quickOpenService: IQuickOpenService; static ID = 'workbench.action.debug.launch'; - static LABEL = nls.localize('launchDebugConfiguration', "Select Debug Configuration to Launch"); + static LABEL = nls.localize('launchDebugConfiguration', "Select and Start Debugging"); constructor(id: string, label: string, @IDebugService debugService: IDebugService, From c0c00dd2b985c990345a80b98afdcd242c57852d Mon Sep 17 00:00:00 2001 From: Michel Kaporin Date: Tue, 21 Feb 2017 10:36:27 +0100 Subject: [PATCH 4/6] Removed redundant methods, corrected aria label. --- .../parts/debug/browser/debugQuickOpen.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts index f5bd9c6ae9e0e..7547920aa25b5 100644 --- a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts +++ b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts @@ -60,7 +60,7 @@ export class QuickOpenHandler extends Quickopen.QuickOpenHandler { } public getAriaLabel(): string { - return nls.localize('debugAriaLabel', "Type the name of a launch configuration to run"); + return nls.localize('debugAriaLabel', "Type a name of a launch configuration to run."); } public getResults(input: string): TPromise { @@ -73,28 +73,12 @@ export class QuickOpenHandler extends Quickopen.QuickOpenHandler { return TPromise.as(new Model.QuickOpenModel(configurationNames)); } - public getClass(): string { - return null; - } - - public canRun(): boolean { - return true; - } - public getAutoFocus(input: string): QuickOpen.IAutoFocus { return { autoFocusFirstEntry: !!input }; } - public onClose(cancelled: boolean): void { - return; - } - - public getGroupLabel(): string { - return null; - } - public getEmptyLabel(searchString: string): string { if (searchString.length > 0) { return nls.localize('noConfigurationsMatching', "No debug configurations matching"); From 7bacf5dafcf9632fd2ec76ff6c87ea8a06109f75 Mon Sep 17 00:00:00 2001 From: Michel Kaporin Date: Tue, 21 Feb 2017 12:10:25 +0100 Subject: [PATCH 5/6] Tidy up after PR review. --- .../parts/debug/browser/debugActions.ts | 13 +++++------ .../parts/debug/browser/debugQuickOpen.ts | 22 +++++-------------- .../electron-browser/debug.contribution.ts | 4 ++-- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index b8db1925e41a2..b093867248362 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -211,10 +211,9 @@ export class RunAction extends StartAction { } } -export class LaunchAction extends RunAction { - private quickOpenService: IQuickOpenService; - static ID = 'workbench.action.debug.launch'; - static LABEL = nls.localize('launchDebugConfiguration', "Select and Start Debugging"); +export class SelectAndStartAction extends AbstractDebugAction { + static ID = 'workbench.action.debug.selectandstart'; + static LABEL = nls.localize('selectAndStartDebugging', "Select and Start Debugging"); constructor(id: string, label: string, @IDebugService debugService: IDebugService, @@ -222,14 +221,14 @@ export class LaunchAction extends RunAction { @ICommandService commandService: ICommandService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IFileService fileService: IFileService, - @IQuickOpenService quickOpenService: IQuickOpenService + @IQuickOpenService private quickOpenService: IQuickOpenService ) { - super(id, label, debugService, keybindingService, commandService, contextService, fileService); + super(id, label, undefined, debugService, keybindingService); this.quickOpenService = quickOpenService; } public run(): TPromise { - return TPromise.as(this.quickOpenService.show('debug ')); + return this.quickOpenService.show('debug '); } } diff --git a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts index 7547920aa25b5..78dc57492e981 100644 --- a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts +++ b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts @@ -2,7 +2,6 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; import nls = require('vs/nls'); import Filters = require('vs/base/common/filters'); @@ -15,13 +14,9 @@ import { IDebugService } from 'vs/workbench/parts/debug/common/debug'; import * as errors from 'vs/base/common/errors'; class DebugEntry extends Model.QuickOpenEntry { - private debugService: IDebugService; - private configurationName: string; - constructor(debugService: IDebugService, config: string, highlights: Model.IHighlight[] = []) { + constructor(private debugService: IDebugService, private configurationName: string, highlights: Model.IHighlight[] = []) { super(highlights); - this.debugService = debugService; - this.configurationName = config; } public getLabel(): string { @@ -37,8 +32,8 @@ class DebugEntry extends Model.QuickOpenEntry { return false; } // Run selected debug configuration - this.debugService.createProcess(this.configurationName).done(undefined, errors.onUnexpectedError); this.debugService.getViewModel().setSelectedConfigurationName(this.configurationName); + this.debugService.createProcess(this.configurationName).done(undefined, errors.onUnexpectedError); return true; } @@ -46,17 +41,11 @@ class DebugEntry extends Model.QuickOpenEntry { export class QuickOpenHandler extends Quickopen.QuickOpenHandler { - private debugService: IDebugService; - private quickOpenService: IQuickOpenService; - constructor( - @IQuickOpenService quickOpenService: IQuickOpenService, - @IDebugService debugService: IDebugService + @IQuickOpenService private quickOpenService: IQuickOpenService, + @IDebugService private debugService: IDebugService ) { super(); - - this.quickOpenService = quickOpenService; - this.debugService = debugService; } public getAriaLabel(): string { @@ -65,7 +54,6 @@ export class QuickOpenHandler extends Quickopen.QuickOpenHandler { public getResults(input: string): TPromise { const configurationNames = this.debugService.getConfigurationManager().getConfigurationNames() - .sort((a, b) => a.localeCompare(b)) .map(config => ({ config: config, highlights: Filters.matchesContiguousSubString(input, config) })) .filter(({ highlights }) => !!highlights) .map(({ config, highlights }) => new DebugEntry(this.debugService, config, highlights)); @@ -84,6 +72,6 @@ export class QuickOpenHandler extends Quickopen.QuickOpenHandler { return nls.localize('noConfigurationsMatching', "No debug configurations matching"); } - return nls.localize('noConfigurationsFound', "No debug configurations found"); + return nls.localize('noConfigurationsFound', "No debug configurations found. Please create a 'launch.json' file."); } } \ No newline at end of file diff --git a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts index d8472888ece64..69d73e0b57aa3 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts @@ -25,7 +25,7 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { DebugEditorModelManager } from 'vs/workbench/parts/debug/browser/debugEditorModelManager'; import { StepOverAction, ClearReplAction, FocusReplAction, StepIntoAction, StepOutAction, StartAction, RestartAction, ContinueAction, StopAction, DisconnectAction, PauseAction, AddFunctionBreakpointAction, - ConfigureAction, DisableAllBreakpointsAction, EnableAllBreakpointsAction, RemoveAllBreakpointsAction, RunAction, ReapplyBreakpointsAction, LaunchAction + ConfigureAction, DisableAllBreakpointsAction, EnableAllBreakpointsAction, RemoveAllBreakpointsAction, RunAction, ReapplyBreakpointsAction, SelectAndStartAction } from 'vs/workbench/parts/debug/browser/debugActions'; import { DebugActionsWidget } from 'vs/workbench/parts/debug/browser/debugActionsWidget'; import * as service from 'vs/workbench/parts/debug/electron-browser/debugService'; @@ -128,7 +128,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(EnableAllBreakpointsAc registry.registerWorkbenchAction(new SyncActionDescriptor(DisableAllBreakpointsAction, DisableAllBreakpointsAction.ID, DisableAllBreakpointsAction.LABEL), 'Debug: Disable All Breakpoints', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(ClearReplAction, ClearReplAction.ID, ClearReplAction.LABEL), 'Debug: Clear Debug Console', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(FocusReplAction, FocusReplAction.ID, FocusReplAction.LABEL), 'Debug: Focus Debug Console', debugCategory); -registry.registerWorkbenchAction(new SyncActionDescriptor(LaunchAction, LaunchAction.ID, LaunchAction.LABEL, null, CONTEXT_NOT_IN_DEBUG_MODE), 'Debug: Launch Configuration', debugCategory); +registry.registerWorkbenchAction(new SyncActionDescriptor(SelectAndStartAction, SelectAndStartAction.ID, SelectAndStartAction.LABEL), 'Debug: Launch Configuration', debugCategory); // Register Quick Open (Registry.as(QuickOpenExtensions.Quickopen)).registerQuickOpenHandler( From 70010515a005459474e381e9932528caa69bb6c9 Mon Sep 17 00:00:00 2001 From: Michel Kaporin Date: Tue, 21 Feb 2017 12:11:56 +0100 Subject: [PATCH 6/6] Newline added. --- src/vs/workbench/parts/debug/browser/debugQuickOpen.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts index 78dc57492e981..b2a1601996156 100644 --- a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts +++ b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts @@ -74,4 +74,4 @@ export class QuickOpenHandler extends Quickopen.QuickOpenHandler { return nls.localize('noConfigurationsFound', "No debug configurations found. Please create a 'launch.json' file."); } -} \ No newline at end of file +}