@@ -9,22 +9,18 @@ import * as vscode from 'vscode';
99import { URI } from 'vs/base/common/uri' ;
1010import { posix } from 'path' ;
1111import { OutputAppender } from 'vs/platform/output/node/outputAppender' ;
12- import { TPromise } from 'vs/base/common/winjs.base' ;
1312
1413export abstract class AbstractExtHostOutputChannel implements vscode . OutputChannel {
1514
16- private static _idPool = 1 ;
17-
18- protected readonly _id : string ;
15+ protected readonly _id : Thenable < string > ;
1916 private readonly _name : string ;
2017 protected readonly _proxy : MainThreadOutputServiceShape ;
21- protected _registerationPromise : Thenable < void > = TPromise . as ( null ) ;
2218 private _disposed : boolean ;
2319
24- constructor ( name : string , proxy : MainThreadOutputServiceShape ) {
25- this . _id = 'extension-output-#' + ( AbstractExtHostOutputChannel . _idPool ++ ) ;
20+ constructor ( name : string , file : URI , proxy : MainThreadOutputServiceShape ) {
2621 this . _name = name ;
2722 this . _proxy = proxy ;
23+ this . _id = proxy . $register ( this . name , file ) ;
2824 }
2925
3026 get name ( ) : string {
@@ -40,17 +36,17 @@ export abstract class AbstractExtHostOutputChannel implements vscode.OutputChann
4036
4137 clear ( ) : void {
4238 this . validate ( ) ;
43- this . _registerationPromise . then ( ( ) => this . _proxy . $clear ( this . _id ) ) ;
39+ this . _id . then ( id => this . _proxy . $clear ( id ) ) ;
4440 }
4541
4642 show ( columnOrPreserveFocus ?: vscode . ViewColumn | boolean , preserveFocus ?: boolean ) : void {
4743 this . validate ( ) ;
48- this . _registerationPromise . then ( ( ) => this . _proxy . $reveal ( this . _id , typeof columnOrPreserveFocus === 'boolean' ? columnOrPreserveFocus : preserveFocus ) ) ;
44+ this . _id . then ( id => this . _proxy . $reveal ( id , typeof columnOrPreserveFocus === 'boolean' ? columnOrPreserveFocus : preserveFocus ) ) ;
4945 }
5046
5147 hide ( ) : void {
5248 this . validate ( ) ;
53- this . _registerationPromise . then ( ( ) => this . _proxy . $close ( this . _id ) ) ;
49+ this . _id . then ( id => this . _proxy . $close ( id ) ) ;
5450 }
5551
5652 protected validate ( ) : void {
@@ -61,8 +57,8 @@ export abstract class AbstractExtHostOutputChannel implements vscode.OutputChann
6157
6258 dispose ( ) : void {
6359 if ( ! this . _disposed ) {
64- this . _registerationPromise
65- . then ( ( ) => this . _proxy . $dispose ( this . _id ) )
60+ this . _id
61+ . then ( id => this . _proxy . $dispose ( id ) )
6662 . then ( ( ) => this . _disposed = true ) ;
6763 }
6864 }
@@ -71,26 +67,26 @@ export abstract class AbstractExtHostOutputChannel implements vscode.OutputChann
7167export class ExtHostOutputChannel extends AbstractExtHostOutputChannel {
7268
7369 constructor ( name : string , proxy : MainThreadOutputServiceShape ) {
74- super ( name , proxy ) ;
75- this . _registerationPromise = proxy . $register ( this . _id , name ) ;
70+ super ( name , null , proxy ) ;
7671 }
7772
7873 append ( value : string ) : void {
7974 this . validate ( ) ;
80- this . _registerationPromise . then ( ( ) => this . _proxy . $append ( this . _id , value ) ) ;
75+ this . _id . then ( id => this . _proxy . $append ( id , value ) ) ;
8176 }
8277}
8378
8479export class ExtHostLoggingOutputChannel extends AbstractExtHostOutputChannel {
8580
81+ private static _namePool = 1 ;
8682 private _appender : OutputAppender ;
8783
8884 constructor ( name : string , outputDir : string , proxy : MainThreadOutputServiceShape ) {
89- super ( name , proxy ) ;
90- const file = URI . file ( posix . join ( outputDir , `${ this . _id } .log` ) ) ;
91- this . _appender = new OutputAppender ( this . _id , file . fsPath ) ;
92- this . _registerationPromise = proxy . $register ( this . _id , this . name , file ) ;
85+ const fileName = `${ ExtHostLoggingOutputChannel . _namePool ++ } -${ name } ` ;
86+ const file = URI . file ( posix . join ( outputDir , `${ fileName } .log` ) ) ;
9387
88+ super ( name , file , proxy ) ;
89+ this . _appender = new OutputAppender ( fileName , file . fsPath ) ;
9490 }
9591
9692 append ( value : string ) : void {
0 commit comments