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