提交 67c70614 编写于 作者: S Sandeep Somavarapu

clean up

上级 804061b6
...@@ -271,10 +271,7 @@ export class OutputService implements IOutputService { ...@@ -271,10 +271,7 @@ export class OutputService implements IOutputService {
} }
if (this.activeChannelId) { if (this.activeChannelId) {
const activeChannel = <OutputChannel>this.getChannel(this.activeChannelId); this.doHideChannel(this.activeChannelId);
if (activeChannel) {
activeChannel.hide();
}
} }
this.activeChannelId = id; this.activeChannelId = id;
...@@ -285,16 +282,24 @@ export class OutputService implements IOutputService { ...@@ -285,16 +282,24 @@ export class OutputService implements IOutputService {
getChannel(id: string): IOutputChannel { getChannel(id: string): IOutputChannel {
if (!this.channels.has(id)) { if (!this.channels.has(id)) {
const channelData = Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).getChannel(id); const channelData = Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).getChannel(id);
const channel = channelData && channelData.file ? this.instantiationService.createInstance(FileOutputChannel, channelData) : this.instantiationService.createInstance(BufferredOutputChannel, { id: id, label: '' }); const channelDisposables = channelData && channelData.file ? this.instantiationService.createInstance(FileOutputChannel, channelData) : this.instantiationService.createInstance(BufferredOutputChannel, { id: id, label: '' });
let disposables = []; let disposables = [];
channel.onDidChange(isClear => this._onOutput.fire({ channelId: id, isClear }), disposables); channelDisposables.onDidChange(isClear => this._onOutput.fire({ channelId: id, isClear }), disposables);
channel.onDispose(() => { channelDisposables.onDispose(() => {
this.removeOutput(id); Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).removeChannel(id);
if (this.activeChannelId === id) {
const channels = this.getChannels();
if (this._outputPanel && channels.length) {
this.showChannel(channels[0].id);
} else {
this._onActiveOutputChannel.fire(void 0);
}
}
dispose(disposables); dispose(disposables);
}, disposables); }, disposables);
this.channels.set(id, channel); this.channels.set(id, channelDisposables);
} }
return this.channels.get(id); return this.channels.get(id);
} }
...@@ -314,6 +319,9 @@ export class OutputService implements IOutputService { ...@@ -314,6 +319,9 @@ export class OutputService implements IOutputService {
private onDidPanelClose(panel: IPanel): void { private onDidPanelClose(panel: IPanel): void {
if (this._outputPanel && panel.getId() === OUTPUT_PANEL_ID) { if (this._outputPanel && panel.getId() === OUTPUT_PANEL_ID) {
if (this.activeChannelId) {
this.doHideChannel(this.activeChannelId);
}
this._outputPanel.clearInput(); this._outputPanel.clearInput();
} }
} }
...@@ -327,21 +335,9 @@ export class OutputService implements IOutputService { ...@@ -327,21 +335,9 @@ export class OutputService implements IOutputService {
} }
} }
private removeOutput(channelId: string): void {
Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).removeChannel(channelId);
if (this.activeChannelId === channelId) {
const channels = this.getChannels();
if (this._outputPanel && channels.length) {
this.showChannel(channels[0].id);
} else {
this._onActiveOutputChannel.fire(void 0);
}
}
}
private doShowChannel(channelId: string, preserveFocus: boolean): TPromise<void> { private doShowChannel(channelId: string, preserveFocus: boolean): TPromise<void> {
const activeChannel = <OutputChannel>this.getChannel(channelId); const channel = <OutputChannel>this.getChannel(channelId);
return activeChannel.show() return channel.show()
.then(() => { .then(() => {
this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, channelId, StorageScope.WORKSPACE); this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, channelId, StorageScope.WORKSPACE);
this._outputPanel.setInput(this.createInput(this.getChannel(channelId)), EditorOptions.create({ preserveFocus: preserveFocus })); this._outputPanel.setInput(this.createInput(this.getChannel(channelId)), EditorOptions.create({ preserveFocus: preserveFocus }));
...@@ -351,6 +347,13 @@ export class OutputService implements IOutputService { ...@@ -351,6 +347,13 @@ export class OutputService implements IOutputService {
}); });
} }
private doHideChannel(channelId): void {
const channel = <OutputChannel>this.getChannel(channelId);
if (channel) {
channel.hide();
}
}
private createInput(channel: IOutputChannel): ResourceEditorInput { private createInput(channel: IOutputChannel): ResourceEditorInput {
const resource = URI.from({ scheme: OUTPUT_SCHEME, path: channel.id }); const resource = URI.from({ scheme: OUTPUT_SCHEME, path: channel.id });
return this.instantiationService.createInstance(ResourceEditorInput, nls.localize('output', "Output"), channel ? nls.localize('channel', "for '{0}'", channel.label) : '', resource); return this.instantiationService.createInstance(ResourceEditorInput, nls.localize('output', "Output"), channel ? nls.localize('channel', "for '{0}'", channel.label) : '', resource);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册