提交 e8d5a793 编写于 作者: I isidor

output: introduce onActiveOutputChannel

fixes #3892
上级 d292e6b0
......@@ -724,7 +724,7 @@ export class SelectActionItem extends BaseActionItem {
private select: HTMLSelectElement;
private options: string[];
private selected: number;
private toDispose: lifecycle.IDisposable[];
protected toDispose: lifecycle.IDisposable[];
constructor(ctx: any, action: IAction, options: string[], selected: number) {
super(ctx, action);
......
......@@ -8,7 +8,6 @@ import {TPromise} from 'vs/base/common/winjs.base';
import nls = require('vs/nls');
import {Registry} from 'vs/platform/platform';
import arrays = require('vs/base/common/arrays');
import {IDisposable} from 'vs/base/common/lifecycle';
import {IAction, Action} from 'vs/base/common/actions';
import {EditorAction} from 'vs/editor/common/editorAction';
import {Behaviour} from 'vs/editor/common/editorActionEnablement';
......@@ -108,15 +107,14 @@ export class SwitchOutputAction extends Action {
export class SwitchOutputActionItem extends SelectActionItem {
private input: OutputEditorInput;
private outputListenerDispose: IDisposable;
constructor(
action: IAction,
@IOutputService private outputService: IOutputService
) {
super(null, action, SwitchOutputActionItem.getChannels(outputService), Math.max(0, SwitchOutputActionItem.getChannels(outputService).indexOf(outputService.getActiveChannel())));
this.outputListenerDispose = this.outputService.onOutputChannel(this.onOutputChannel, this);
this.toDispose.push(this.outputService.onOutputChannel(this.onOutputChannel, this));
this.toDispose.push(this.outputService.onActiveOutputChannel(this.onOutputChannel, this));
}
private onOutputChannel(): void {
......@@ -135,12 +133,6 @@ export class SwitchOutputActionItem extends SelectActionItem {
public dispose(): void {
super.dispose();
if (this.outputListenerDispose) {
this.outputListenerDispose.dispose();
delete this.outputListenerDispose;
}
delete this.input;
}
}
\ No newline at end of file
}
......@@ -99,6 +99,11 @@ export interface IOutputService {
* Allows to register on a new Output channel getting filled with output
*/
onOutputChannel: Event<string>;
/**
* Allows to register on active output channel change
*/
onActiveOutputChannel: Event<string>;
}
export interface IOutputChannelRegistry {
......
......@@ -30,6 +30,7 @@ export class OutputService implements IOutputService {
private _onOutput: Emitter<IOutputEvent>;
private _onOutputChannel: Emitter<string>;
private _onActiveOutputChannel: Emitter<string>;
constructor(
@IStorageService private storageService: IStorageService,
......@@ -40,6 +41,7 @@ export class OutputService implements IOutputService {
) {
this._onOutput = new Emitter<IOutputEvent>();
this._onOutputChannel = new Emitter<string>();
this._onActiveOutputChannel = new Emitter<string>();
this.receivedOutput = Object.create(null);
......@@ -55,6 +57,10 @@ export class OutputService implements IOutputService {
return this._onOutputChannel.event;
}
public get onActiveOutputChannel(): Event<string> {
return this._onActiveOutputChannel.event;
}
public append(channel: string, output: string): void {
// Initialize
......@@ -114,6 +120,7 @@ export class OutputService implements IOutputService {
public showOutput(channel: string, preserveFocus?: boolean): TPromise<IEditor> {
this.activeChannel = channel;
this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, this.activeChannel, StorageScope.WORKSPACE);
this._onActiveOutputChannel.fire(channel); // emit event that we a new channel is active
return this.panelService.openPanel(OUTPUT_PANEL_ID, !preserveFocus).then((outputPanel: OutputPanel) => {
return outputPanel && outputPanel.setInput(OutputEditorInput.getInstance(this.instantiationService, channel), EditorOptions.create({ preserveFocus: preserveFocus })).
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册