提交 cebddf21 编写于 作者: I isidor

debug: remove disabled state and tune viewlet ux for no folder workspace

上级 1c38df78
......@@ -10,6 +10,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IDebugService, State, IProcess, SessionRequestType, IThread, IEnablement, IBreakpoint, IStackFrame, IFunctionBreakpoint, IDebugEditorContribution, EDITOR_CONTRIBUTION_ID, IExpression, REPL_ID }
from 'vs/workbench/parts/debug/common/debug';
import { Variable, Expression, Thread, Breakpoint, Process } from 'vs/workbench/parts/debug/common/debugModel';
......@@ -18,7 +19,7 @@ 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';
export class AbstractDebugAction extends Action {
export abstract class AbstractDebugAction extends Action {
protected toDispose: lifecycle.IDisposable[];
......@@ -56,7 +57,7 @@ export class AbstractDebugAction extends Action {
}
protected isEnabled(state: State): boolean {
return state !== State.Disabled;
return true;
}
public dispose(): void {
......@@ -69,7 +70,11 @@ export class ConfigureAction extends AbstractDebugAction {
static ID = 'workbench.action.debug.configure';
static LABEL = nls.localize('openLaunchJson', "Open {0}", 'launch.json');
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
constructor(id: string, label: string,
@IDebugService debugService: IDebugService,
@IKeybindingService keybindingService: IKeybindingService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
) {
super(id, label, 'debug-action configure', debugService, keybindingService);
this.toDispose.push(debugService.getViewModel().onDidSelectConfiguration(configurationName => this.updateClass()));
this.updateClass();
......@@ -87,6 +92,10 @@ export class ConfigureAction extends AbstractDebugAction {
this.class = this.debugService.getViewModel().selectedConfigurationName ? 'debug-action configure' : 'debug-action configure notification';
}
protected isEnabled(): boolean {
return !!this.contextService.getWorkspace();
}
public run(event?: any): TPromise<any> {
const sideBySide = !!(event && (event.ctrlKey || event.metaKey));
return this.debugService.getConfigurationManager().openConfigFile(sideBySide);
......@@ -440,7 +449,7 @@ export class ReapplyBreakpointsAction extends AbstractDebugAction {
protected isEnabled(state: State): boolean {
const model = this.debugService.getModel();
return super.isEnabled(state) && state !== State.Disabled && state !== State.Inactive &&
return super.isEnabled(state) && state !== State.Inactive &&
(model.getFunctionBreakpoints().length + model.getBreakpoints().length + model.getExceptionBreakpoints().length > 0);
}
}
......
......@@ -156,7 +156,7 @@ export class DebugActionsWidget implements IWorkbenchContribution {
private update(): void {
const state = this.debugService.state;
if (state === debug.State.Disabled || state === debug.State.Inactive) {
if (state === debug.State.Inactive) {
return this.hide();
}
......
......@@ -202,7 +202,7 @@ export class DebugEditorModelManager implements IWorkbenchContribution {
});
}
}
modelData.dirty = this.debugService.state !== State.Inactive && this.debugService.state !== State.Disabled;
modelData.dirty = this.debugService.state !== State.Inactive;
const toRemove = this.debugService.getModel().getBreakpoints()
.filter(bp => bp.uri.toString() === modelUri.toString());
......
......@@ -4,9 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/debugViewlet';
import * as nls from 'vs/nls';
import * as errors from 'vs/base/common/errors';
import { $, Builder, Dimension } from 'vs/base/browser/builder';
import { Builder, Dimension } from 'vs/base/browser/builder';
import { TPromise } from 'vs/base/common/winjs.base';
import * as lifecycle from 'vs/base/common/lifecycle';
import { IAction } from 'vs/base/common/actions';
......@@ -23,9 +21,7 @@ import { IProgressService, IProgressRunner } from 'vs/platform/progress/common/p
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageService } from 'vs/platform/storage/common/storage';
import env = require('vs/base/common/platform');
import { Button } from 'vs/base/browser/ui/button/button';
import { OpenFolderAction, OpenFileFolderAction } from 'vs/workbench/browser/actions/fileActions';
export class DebugViewlet extends Viewlet {
......@@ -65,40 +61,16 @@ export class DebugViewlet extends Viewlet {
super.create(parent);
this.$el = parent.div().addClass('debug-viewlet');
if (this.contextService.hasWorkspace()) {
const actionRunner = this.getActionRunner();
this.views = DebugViewRegistry.getDebugViews().map(viewConstructor => this.instantiationService.createInstance(
viewConstructor,
actionRunner,
this.viewletSettings)
);
this.splitView = new SplitView(this.$el.getHTMLElement());
this.toDispose.push(this.splitView);
this.views.forEach(v => this.splitView.addView(v));
} else {
const noworkspace = $([
'<div class="noworkspace-view">',
'<p>', nls.localize('noWorkspaceHelp', "You have not yet opened a folder."), '</p>',
'<p>', nls.localize('pleaseRestartToDebug', "Open a folder in order to start debugging."), '</p>',
'</div>'
].join(''));
this.openFolderButton = new Button(noworkspace);
this.openFolderButton.label = nls.localize('openFolder', "Open Folder");
this.openFolderButton.addListener2('click', () => {
const actionClass = env.isMacintosh ? OpenFileFolderAction : OpenFolderAction;
const action = this.instantiationService.createInstance<string, string, IAction>(actionClass, actionClass.ID, actionClass.LABEL);
this.actionRunner.run(action).done(() => {
action.dispose();
}, err => {
action.dispose();
errors.onUnexpectedError(err);
});
});
const actionRunner = this.getActionRunner();
this.views = DebugViewRegistry.getDebugViews().map(viewConstructor => this.instantiationService.createInstance(
viewConstructor,
actionRunner,
this.viewletSettings)
);
this.$el.append(noworkspace);
}
this.splitView = new SplitView(this.$el.getHTMLElement());
this.toDispose.push(this.splitView);
this.views.forEach(v => this.splitView.addView(v));
return TPromise.as(null);
}
......@@ -129,16 +101,13 @@ export class DebugViewlet extends Viewlet {
}
public getActions(): IAction[] {
if (this.debugService.state === State.Disabled) {
return [];
}
if (!this.actions) {
this.actions = [
this.instantiationService.createInstance(StartAction, StartAction.ID, StartAction.LABEL),
this.instantiationService.createInstance(ConfigureAction, ConfigureAction.ID, ConfigureAction.LABEL),
this.instantiationService.createInstance(ToggleReplAction, ToggleReplAction.ID, ToggleReplAction.LABEL)
];
this.actions = [];
this.actions.push(this.instantiationService.createInstance(StartAction, StartAction.ID, StartAction.LABEL));
if (this.contextService.getWorkspace()) {
this.actions.push(this.instantiationService.createInstance(ConfigureAction, ConfigureAction.ID, ConfigureAction.LABEL));
}
this.actions.push(this.instantiationService.createInstance(ToggleReplAction, ToggleReplAction.ID, ToggleReplAction.LABEL));
this.actions.forEach(a => {
this.toDispose.push(a);
......@@ -149,7 +118,7 @@ export class DebugViewlet extends Viewlet {
}
public getActionItem(action: IAction): IActionItem {
if (action.id === StartAction.ID) {
if (action.id === StartAction.ID && this.contextService.getWorkspace()) {
if (!this.startDebugActionItem) {
this.startDebugActionItem = this.instantiationService.createInstance(StartDebugActionItem, null, action);
}
......
......@@ -15,6 +15,10 @@
background: url('configure.svg') center center no-repeat;
}
.monaco-workbench .debug-action.start {
background: url('continue.svg') center center no-repeat;
}
.monaco-workbench .debug-action.toggle-repl {
background: url('repl.svg') center center no-repeat;
}
......@@ -31,6 +35,11 @@
border: 1px solid white;
}
.vs-dark .monaco-workbench .debug-action.start,
.hc-black .monaco-workbench .debug-action.start {
background: url('continue-inverse.svg') center center no-repeat;
}
.vs-dark .monaco-workbench .debug-action.configure,
.hc-black .monaco-workbench .debug-action.configure {
background: url('configure-inverse.svg') center center no-repeat;
......
......@@ -263,7 +263,6 @@ export interface IModel extends ITreeElement {
// Debug enums
export enum State {
Disabled,
Inactive,
Initializing,
Stopped,
......
......@@ -359,7 +359,7 @@ export class DebugService implements debug.IDebugService {
this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidExitAdapter(event => {
// 'Run without debugging' mode VSCode must terminate the extension host. More details: #3905
if (session && session.configuration.type === 'extensionHost' && this.sessionStates.get(session.getId()) === debug.State.RunningNoDebug) {
if (session && session.configuration.type === 'extensionHost' && this.sessionStates.get(session.getId()) === debug.State.RunningNoDebug && this.contextService.getWorkspace()) {
this.windowsService.closeExtensionHostWindow(this.contextService.getWorkspace().resource.fsPath);
}
if (session && session.getId() === event.body.sessionId) {
......@@ -426,10 +426,6 @@ export class DebugService implements debug.IDebugService {
}
public get state(): debug.State {
if (!this.contextService.hasWorkspace()) {
return debug.State.Disabled;
}
const focusedProcess = this.viewModel.focusedProcess;
if (focusedProcess) {
return this.sessionStates.get(focusedProcess.getId());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册