Skip to content

Commit

Permalink
Clients can customize channel creation.
Browse files Browse the repository at this point in the history
 - Fixed text-model is disposed error when
starting/restarting LS.
 - Exposed the channel properties with protected visibility.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
  • Loading branch information
Akos Kitta authored and kittaakos committed Sep 15, 2020
1 parent 4378748 commit 48dfeb8
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/output/src/common/output-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class OutputChannelManager implements CommandContribution, Disposable, Re
this.textModelService.createModelReference(uri).then(ref => editorModelRef.resolve(ref));
}

const channel = new OutputChannel(resource, this.preferences);
const channel = this.createChannel(resource);
this.channels.set(name, channel);
this.toDisposeOnChannelDeletion.set(name, this.registerListeners(channel));
this.channelAddedEmitter.fire(channel);
Expand Down Expand Up @@ -306,6 +306,10 @@ export class OutputChannelManager implements CommandContribution, Disposable, Re
return new OutputResource(uri, editorModelRef);
}

protected createChannel(resource: OutputResource): OutputChannel {
return new OutputChannel(resource, this.preferences);
}

}

export enum OutputChannelSeverity {
Expand All @@ -316,20 +320,21 @@ export enum OutputChannelSeverity {

export class OutputChannel implements Disposable {

private readonly contentChangeEmitter = new Emitter<void>();
private readonly visibilityChangeEmitter = new Emitter<{ isVisible: boolean, preserveFocus?: boolean }>();
private readonly disposedEmitter = new Emitter<void>();
private readonly toDispose = new DisposableCollection(
protected readonly contentChangeEmitter = new Emitter<void>();
protected readonly visibilityChangeEmitter = new Emitter<{ isVisible: boolean, preserveFocus?: boolean }>();
protected readonly disposedEmitter = new Emitter<void>();
protected readonly textModifyQueue = new PQueue({ autoStart: true, concurrency: 1 });
protected readonly toDispose = new DisposableCollection(
Disposable.create(() => this.textModifyQueue.clear()),
this.contentChangeEmitter,
this.visibilityChangeEmitter,
this.disposedEmitter
);

private disposed = false;
private visible = true;
private _maxLineNumber: number;
private decorationIds = new Set<string>();
private textModifyQueue = new PQueue({ autoStart: true, concurrency: 1 });
protected disposed = false;
protected visible = true;
protected _maxLineNumber: number;
protected decorationIds = new Set<string>();

readonly onVisibilityChange: Event<{ isVisible: boolean, preserveFocus?: boolean }> = this.visibilityChangeEmitter.event;
readonly onContentChange: Event<void> = this.contentChangeEmitter.event;
Expand Down

0 comments on commit 48dfeb8

Please sign in to comment.