diff --git a/src/vs/workbench/api/common/extHostOutput.ts b/src/vs/workbench/api/common/extHostOutput.ts index 69fa1b368614bacc68bdbe622013448678736a63..c903d4b484f3fa8a0ea83ce3fdea63a171beb393 100644 --- a/src/vs/workbench/api/common/extHostOutput.ts +++ b/src/vs/workbench/api/common/extHostOutput.ts @@ -7,7 +7,7 @@ import { MainContext, MainThreadOutputServiceShape, ExtHostOutputServiceShape } import * as vscode from 'vscode'; import { URI } from 'vs/base/common/uri'; import { Event, Emitter } from 'vs/base/common/event'; -import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle'; +import { Disposable } from 'vs/base/common/lifecycle'; import { VSBuffer } from 'vs/base/common/buffer'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService'; @@ -140,20 +140,12 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape { readonly _serviceBrand: any; protected readonly _proxy: MainThreadOutputServiceShape; - protected readonly _channels: Map = new Map(); - protected readonly _visibleChannelDisposable = new MutableDisposable(); constructor(@IExtHostRpcService extHostRpc: IExtHostRpcService) { this._proxy = extHostRpc.getProxy(MainContext.MainThreadOutputService); } $setVisibleChannel(channelId: string): void { - if (channelId) { - const channel = this._channels.get(channelId); - if (channel) { - this._visibleChannelDisposable.value = channel.onDidAppend(() => channel.update()); - } - } } createOutputChannel(name: string): vscode.OutputChannel { diff --git a/src/vs/workbench/api/node/extHostOutputService.ts b/src/vs/workbench/api/node/extHostOutputService.ts index 3a69496d9895636cdfaeffe3395f7bb1874d487f..fd194124907aff8620f78d2c5ff808fc7c18c264 100644 --- a/src/vs/workbench/api/node/extHostOutputService.ts +++ b/src/vs/workbench/api/node/extHostOutputService.ts @@ -13,6 +13,7 @@ import { dirExists, mkdirp } from 'vs/base/node/pfs'; import { AbstractExtHostOutputChannel, ExtHostPushOutputChannel, ExtHostOutputService, LazyOutputChannel } from 'vs/workbench/api/common/extHostOutput'; import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService'; import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService'; +import { MutableDisposable } from 'vs/base/common/lifecycle'; export class ExtHostOutputChannelBackedByFile extends AbstractExtHostOutputChannel { @@ -49,6 +50,8 @@ export class ExtHostOutputService2 extends ExtHostOutputService { private _logsLocation: URI; private _namePool: number = 1; + private readonly _channels: Map = new Map(); + private readonly _visibleChannelDisposable = new MutableDisposable(); constructor( @IExtHostRpcService extHostRpc: IExtHostRpcService, @@ -58,12 +61,23 @@ export class ExtHostOutputService2 extends ExtHostOutputService { this._logsLocation = initData.logsLocation; } + $setVisibleChannel(channelId: string): void { + if (channelId) { + const channel = this._channels.get(channelId); + if (channel) { + this._visibleChannelDisposable.value = channel.onDidAppend(() => channel.update()); + } + } + } + createOutputChannel(name: string): vscode.OutputChannel { name = name.trim(); if (!name) { throw new Error('illegal argument `name`. must not be falsy'); } - return new LazyOutputChannel(name, this._doCreateOutChannel(name)); + const extHostOutputChannel = this._doCreateOutChannel(name); + extHostOutputChannel.then(channel => channel._id.then(id => this._channels.set(id, channel))); + return new LazyOutputChannel(name, extHostOutputChannel); } private async _doCreateOutChannel(name: string): Promise {