提交 bf2f9210 编写于 作者: I isidor

Fix problems when starting debug from status line

fixes #37507
上级 ac77bc03
......@@ -132,16 +132,15 @@ export class StartAction extends AbstractDebugAction {
return false;
}
// Disabled if the launch drop down shows the launch config that is already running.
protected isEnabled(state: State): boolean {
const processes = this.debugService.getModel().getProcesses();
const selectedName = this.debugService.getConfigurationManager().selectedName;
const launch = this.debugService.getConfigurationManager().selectedLaunch;
public static isEnabled(debugService: IDebugService, contextService: IWorkspaceContextService) {
const processes = debugService.getModel().getProcesses();
const selectedName = debugService.getConfigurationManager().selectedName;
const launch = debugService.getConfigurationManager().selectedLaunch;
if (state === State.Initializing) {
if (debugService.state === State.Initializing) {
return false;
}
if (this.contextService && this.contextService.getWorkbenchState() === WorkbenchState.EMPTY && processes.length > 0) {
if (contextService && contextService.getWorkbenchState() === WorkbenchState.EMPTY && processes.length > 0) {
return false;
}
if (processes.some(p => p.getName(false) === selectedName && (!launch || p.session.root.uri.toString() === launch.workspace.uri.toString()))) {
......@@ -154,6 +153,11 @@ export class StartAction extends AbstractDebugAction {
return true;
}
// Disabled if the launch drop down shows the launch config that is already running.
protected isEnabled(state: State): boolean {
return StartAction.isEnabled(this.debugService, this.contextService);
}
}
export class RunAction extends StartAction {
......
......@@ -14,6 +14,9 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/
import * as errors from 'vs/base/common/errors';
import { QuickOpenEntry, QuickOpenEntryGroup } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { StartAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { IMessageService } from 'vs/platform/message/common/message';
import { Severity } from 'vs/workbench/services/message/browser/messageList';
class AddConfigEntry extends Model.QuickOpenEntry {
......@@ -45,7 +48,7 @@ class AddConfigEntry extends Model.QuickOpenEntry {
class StartDebugEntry extends Model.QuickOpenEntry {
constructor(private debugService: IDebugService, private contextService: IWorkspaceContextService, private launch: ILaunch, private configurationName: string, highlights: Model.IHighlight[] = []) {
constructor(private debugService: IDebugService, private contextService: IWorkspaceContextService, private messageService: IMessageService, private launch: ILaunch, private configurationName: string, highlights: Model.IHighlight[] = []) {
super(highlights);
}
......@@ -62,12 +65,12 @@ class StartDebugEntry extends Model.QuickOpenEntry {
}
public run(mode: QuickOpen.Mode, context: Model.IContext): boolean {
if (mode === QuickOpen.Mode.PREVIEW) {
if (mode === QuickOpen.Mode.PREVIEW || !StartAction.isEnabled(this.debugService, this.contextService)) {
return false;
}
// Run selected debug configuration
this.debugService.getConfigurationManager().selectConfiguration(this.launch, this.configurationName);
this.debugService.startDebugging(this.launch.workspace).done(undefined, errors.onUnexpectedError);
this.debugService.startDebugging(this.launch.workspace).done(undefined, e => this.messageService.show(Severity.Error, e));
return true;
}
......@@ -81,7 +84,8 @@ export class DebugQuickOpenHandler extends Quickopen.QuickOpenHandler {
constructor(
@IDebugService private debugService: IDebugService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@ICommandService private commandService: ICommandService
@ICommandService private commandService: ICommandService,
@IMessageService private messageService: IMessageService
) {
super();
}
......@@ -102,7 +106,7 @@ export class DebugQuickOpenHandler extends Quickopen.QuickOpenHandler {
if (launch === configManager.selectedLaunch && config === configManager.selectedName) {
this.autoFocusIndex = configurations.length;
}
configurations.push(new StartDebugEntry(this.debugService, this.contextService, launch, config, highlights));
configurations.push(new StartDebugEntry(this.debugService, this.contextService, this.messageService, launch, config, highlights));
});
}
launches.forEach((l, index) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册