Skip to content

Commit c7a3171

Browse files
committed
output: move getOutput to IOutputChannel
1 parent 166a9c4 commit c7a3171

3 files changed

Lines changed: 23 additions & 25 deletions

File tree

src/vs/workbench/parts/output/common/output.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ export interface IOutputService {
5656

5757
getOutputChannel(id: string): IOutputChannel;
5858

59-
/**
60-
* Returns the received output.
61-
*
62-
* The optional channel allows to ask for output for a specific channel. If you leave the
63-
* channel out, you get the default channels output.
64-
*/
65-
getOutput(channel: string): string;
66-
6759
/**
6860
* Returns all channels that received output in the current session.
6961
*/
@@ -93,19 +85,24 @@ export interface IOutputService {
9385
export interface IOutputChannel {
9486

9587
/**
96-
* Appends output to the channel.
88+
* The received output content.
9789
*/
98-
append(output: string): void;
90+
getContent(): string;
9991

10092
/**
101-
* Clears all received output.
93+
* Appends output to the channel.
10294
*/
103-
clear(): void;
95+
append(output: string): void;
10496

10597
/**
10698
* Opens the output for this channel.
10799
*/
108100
show(preserveFocus?: boolean): TPromise<IEditor>;
101+
102+
/**
103+
* Clears all received output.
104+
*/
105+
clear(): void;
109106
}
110107

111108
export interface IOutputChannelRegistry {

src/vs/workbench/parts/output/common/outputEditorInput.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class OutputEditorInput extends StringEditorInput {
2727
private static instances: { [channel: string]: OutputEditorInput; } = Object.create(null);
2828

2929
private outputSet: boolean;
30-
private channel: string;
30+
private channelId: string;
3131
private bufferedOutput: string;
3232
private toDispose: lifecycle.IDisposable[];
3333
private appendOutputScheduler: RunOnceScheduler;
@@ -47,15 +47,15 @@ export class OutputEditorInput extends StringEditorInput {
4747
}
4848

4949
constructor(
50-
channel: string,
50+
channelId: string,
5151
@IInstantiationService instantiationService: IInstantiationService,
5252
@IOutputService private outputService: IOutputService,
5353
@IPanelService private panelService: IPanelService,
5454
@IEventService private eventService: IEventService
5555
) {
56-
super(nls.localize('output', "Output"), channel ? nls.localize('outputChannel', "for '{0}'", channel) : '', '', OUTPUT_MIME, true, instantiationService);
56+
super(nls.localize('output', "Output"), channelId ? nls.localize('outputChannel', "for '{0}'", channelId) : '', '', OUTPUT_MIME, true, instantiationService);
5757

58-
this.channel = channel;
58+
this.channelId = channelId;
5959
this.bufferedOutput = '';
6060
this.toDispose = [];
6161
this.toDispose.push(this.outputService.onOutput(this.onOutputReceived, this));
@@ -75,7 +75,7 @@ export class OutputEditorInput extends StringEditorInput {
7575

7676
private appendOutput(): void {
7777
if (this.value.length + this.bufferedOutput.length > MAX_OUTPUT_LENGTH) {
78-
this.setValue(this.outputService.getOutput(this.channel));
78+
this.setValue(this.outputService.getOutputChannel(this.channelId).getContent());
7979
} else {
8080
this.append(this.bufferedOutput);
8181
}
@@ -86,7 +86,7 @@ export class OutputEditorInput extends StringEditorInput {
8686
}
8787

8888
private onOutputReceived(e: IOutputEvent): void {
89-
if (this.outputSet && e.channelId === this.channel) {
89+
if (this.outputSet && e.channelId === this.channelId) {
9090
if (e.output) {
9191
this.bufferedOutput = strings.appendWithLimit(this.bufferedOutput, e.output, MAX_OUTPUT_LENGTH);
9292
this.scheduleOutputAppend();
@@ -98,7 +98,7 @@ export class OutputEditorInput extends StringEditorInput {
9898

9999
private isVisible(): boolean {
100100
const panel = this.panelService.getActivePanel();
101-
return panel && panel.getId() === OUTPUT_PANEL_ID && this.outputService.getActiveChannel() === this.channel;
101+
return panel && panel.getId() === OUTPUT_PANEL_ID && this.outputService.getActiveChannel() === this.channelId;
102102
}
103103

104104
private scheduleOutputAppend(): void {
@@ -118,21 +118,21 @@ export class OutputEditorInput extends StringEditorInput {
118118
return model;
119119
}
120120

121-
this.setValue(this.outputService.getOutput(this.channel));
121+
this.setValue(this.outputService.getOutputChannel(this.channelId).getContent());
122122
this.outputSet = true;
123123

124124
return model;
125125
});
126126
}
127127

128128
public getChannel(): string {
129-
return this.channel;
129+
return this.channelId;
130130
}
131131

132132
public matches(otherInput: any): boolean {
133133
if (otherInput instanceof OutputEditorInput) {
134134
let otherOutputEditorInput = <OutputEditorInput>otherInput;
135-
if (otherOutputEditorInput.getChannel() === this.channel) {
135+
if (otherOutputEditorInput.getChannel() === this.channelId) {
136136
return super.matches(otherInput);
137137
}
138138
}

src/vs/workbench/parts/output/common/outputServices.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ export class OutputService implements IOutputService {
6262

6363
public getOutputChannel(id: string): IOutputChannel {
6464
return {
65+
getContent: () => this.getOutput(id),
6566
append: (output: string) => this.append(id, output),
66-
clear: () => this.clearOutput(id),
67-
show: (preserveFocus: boolean) => this.showOutput(id, preserveFocus)
67+
show: (preserveFocus: boolean) => this.showOutput(id, preserveFocus),
68+
clear: () => this.clearOutput(id)
6869
};
6970
}
7071

@@ -88,7 +89,7 @@ export class OutputService implements IOutputService {
8889
this._onOutput.fire({ output: output, channelId: channelId });
8990
}
9091

91-
public getOutput(channelId: string): string {
92+
private getOutput(channelId: string): string {
9293
return this.receivedOutput[channelId] || '';
9394
}
9495

0 commit comments

Comments
 (0)