提交 e8d2c37d 编写于 作者: I isidor

debugActionItems: polish

上级 3146507f
......@@ -5,7 +5,6 @@
import nls = require('vs/nls');
import errors = require('vs/base/common/errors');
import { TPromise } from 'vs/base/common/winjs.base';
import { IAction } from 'vs/base/common/actions';
import { SelectActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
......@@ -21,10 +20,10 @@ export class DebugSelectActionItem extends SelectActionItem {
super(null, action, [], -1);
this.toDispose.push(configurationService.onDidUpdateConfiguration(e => {
this.updateOptions(true).done(null, errors.onUnexpectedError);
this.updateOptions(true);
}));
this.toDispose.push(this.debugService.getViewModel().onDidSelectConfigurationName(name => {
this.updateOptions(false).done(null, errors.onUnexpectedError);
this.updateOptions(false);
}));
this.toDispose.push(this.debugService.onDidChangeState(() => {
this.enabled = this.debugService.state === State.Inactive;
......@@ -33,23 +32,22 @@ export class DebugSelectActionItem extends SelectActionItem {
public render(container: HTMLElement): void {
super.render(container);
this.updateOptions(true).done(null, errors.onUnexpectedError);
this.updateOptions(true);
this.enabled = this.debugService.state === State.Inactive;
}
private updateOptions(changeDebugConfiguration: boolean): TPromise<any> {
private updateOptions(changeDebugConfiguration: boolean): void {
const config = this.configurationService.getConfiguration<IGlobalConfig>('launch');
if (!config || !config.configurations || config.configurations.length === 0) {
this.setOptions([nls.localize('noConfigurations', "No Configurations")], 0);
return changeDebugConfiguration ? this.actionRunner.run(this._action, null) : TPromise.as(null);
} else {
const configurationNames = config.configurations.filter(cfg => !!cfg.name).map(cfg => cfg.name);
const selected = configurationNames.indexOf(this.debugService.getViewModel().selectedConfigurationName);
this.setOptions(configurationNames, selected);
}
const configurationNames = config.configurations.filter(cfg => !!cfg.name).map(cfg => cfg.name);
const selected = configurationNames.indexOf(this.debugService.getViewModel().selectedConfigurationName);
this.setOptions(configurationNames, selected);
if (changeDebugConfiguration) {
return this.actionRunner.run(this._action, this.getSelected());
this.actionRunner.run(this._action, this.getSelected()).done(null, errors.onUnexpectedError);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册