-
Notifications
You must be signed in to change notification settings - Fork 28.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to select and launch debug configuration #20979
Changes from 5 commits
5113e0c
a19e72c
a369897
7fec350
c0c00dd
7bacf5d
7001051
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename to SelectAndStartAction, also change the id, nls.id |
||
private quickOpenService: IQuickOpenService; | ||
static ID = 'workbench.action.debug.launch'; | ||
static LABEL = nls.localize('launchDebugConfiguration', "Select and Start Debugging"); | ||
|
||
constructor(id: string, label: string, | ||
@IDebugService debugService: IDebugService, | ||
@IKeybindingService keybindingService: IKeybindingService, | ||
@ICommandService commandService: ICommandService, | ||
@IWorkspaceContextService contextService: IWorkspaceContextService, | ||
@IFileService fileService: IFileService, | ||
@IQuickOpenService quickOpenService: IQuickOpenService | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put private for quickOpenService |
||
) { | ||
super(id, label, debugService, keybindingService, commandService, contextService, fileService); | ||
this.quickOpenService = quickOpenService; | ||
} | ||
|
||
public run(): TPromise<any> { | ||
return TPromise.as(this.quickOpenService.show('debug ')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not wrap as promise |
||
} | ||
} | ||
|
||
export class RestartAction extends AbstractDebugAction { | ||
static ID = 'workbench.action.debug.restart'; | ||
static LABEL = nls.localize('restartDebug', "Restart"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We no longer 'use strict', this is simply ignored |
||
|
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get rid of this privates |
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do it the other way around |
||
this.debugService.getViewModel().setSelectedConfigurationName(this.configurationName); | ||
|
||
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 a name of a launch configuration to run."); | ||
} | ||
|
||
public getResults(input: string): TPromise<Model.QuickOpenModel> { | ||
const configurationNames = this.debugService.getConfigurationManager().getConfigurationNames() | ||
.sort((a, b) => a.localeCompare(b)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not sort |
||
.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 getAutoFocus(input: string): QuickOpen.IAutoFocus { | ||
return { | ||
autoFocusFirstEntry: !!input | ||
}; | ||
} | ||
|
||
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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update label to also contain '. Please create a 'launch.json' file.' |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -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; | ||
|
@@ -127,6 +128,17 @@ 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove null and context for now |
||
|
||
// Register Quick Open | ||
(<IQuickOpenRegistry>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); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extend from abstractdebugAction