Skip to content

Commit 166a9c4

Browse files
committed
output: move show output to IOutputChannel
1 parent 346a698 commit 166a9c4

10 files changed

Lines changed: 32 additions & 35 deletions

File tree

src/vs/workbench/api/node/extHostOutputService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class MainThreadOutputService {
9898
}
9999

100100
public reveal(channel: string, preserveFocus: boolean): TPromise<void> {
101-
this._outputService.showOutput(channel, preserveFocus);
101+
this._outputService.getOutputChannel(channel).show(preserveFocus);
102102
return undefined;
103103
}
104104

src/vs/workbench/parts/extensions/electron-browser/extensionsWidgets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class ExtensionsStatusbarItem implements IStatusbarItem {
117117

118118
const outputChannel = this.outputService.getOutputChannel(ExtensionsChannelId);
119119
outputChannel.append(message);
120-
this.outputService.showOutput(ExtensionsLabel, true);
120+
this.outputService.getOutputChannel(ExtensionsChannelId).show(true);
121121
});
122122
});
123123
}

src/vs/workbench/parts/git/browser/gitServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ export class GitService extends ee.EventEmitter
689689
}
690690

691691
var error: Error;
692-
var showOutputAction = new actions.Action('show.gitOutput', nls.localize('showOutput', "Show Output"), null, true, () => this.outputService.showOutput('Git'));
692+
var showOutputAction = new actions.Action('show.gitOutput', nls.localize('showOutput', "Show Output"), null, true, () => this.outputService.getOutputChannel('Git').show());
693693
var cancelAction = new actions.Action('close.message', nls.localize('cancel', "Cancel"), null, true, ()=>winjs.TPromise.as(true));
694694

695695
error = errors.create(

src/vs/workbench/parts/git/browser/gitWorkbenchContributions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ export function registerContributions(): void {
452452

453453
// Register Output Channel
454454
var outputChannelRegistry = <output.IOutputChannelRegistry>platform.Registry.as(output.Extensions.OutputChannels);
455-
outputChannelRegistry.registerChannel('git', nls.localize('git', "Git"));
455+
outputChannelRegistry.registerChannel('Git', nls.localize('git', "Git"));
456456

457457
// Register Git Output
458458
(<ext.IWorkbenchContributionsRegistry>platform.Registry.as(ext.Extensions.Workbench)).registerWorkbenchContribution(

src/vs/workbench/parts/git/browser/views/changes/changesView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
264264
this.instantiationService.createInstance(GitActions.GlobalUnstageAction),
265265
this.instantiationService.createInstance(GitActions.GlobalUndoAction),
266266
new ActionBar.Separator(),
267-
new Actions.Action('show.gitOutput', nls.localize('showOutput', "Show Git Output"), null, true, () => this.outputService.showOutput('Git'))
267+
new Actions.Action('show.gitOutput', nls.localize('showOutput', "Show Git Output"), null, true, () => this.outputService.getOutputChannel('Git').show())
268268
];
269269

270270
this.secondaryActions.forEach(a => this.toDispose.push(a));

src/vs/workbench/parts/output/browser/outputActions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class ToggleOutputAction extends Action {
3939
return TPromise.as(null);
4040
}
4141

42-
return this.outputService.showOutput(this.outputService.getActiveChannel());
42+
return this.outputService.getOutputChannel(this.outputService.getActiveChannel()).show();
4343
}
4444
}
4545

@@ -99,8 +99,8 @@ export class SwitchOutputAction extends Action {
9999
this.class = 'output-action switch-to-output';
100100
}
101101

102-
public run(channel?: string): TPromise<any> {
103-
return this.outputService.showOutput(channel);
102+
public run(channelId?: string): TPromise<any> {
103+
return this.outputService.getOutputChannel(channelId).show();
104104
}
105105
}
106106

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,6 @@ export interface IOutputService {
7474
*/
7575
getActiveChannel(): string;
7676

77-
/**
78-
* Opens the output for the given channel
79-
*
80-
* The optional channel allows to show the output for a specific channel. If you leave the
81-
* channel out, you show the default channels output.
82-
*/
83-
showOutput(channel: string, preserveFocus?: boolean): TPromise<IEditor>;
84-
8577
/**
8678
* Allows to register on Output events
8779
*/
@@ -105,11 +97,15 @@ export interface IOutputChannel {
10597
*/
10698
append(output: string): void;
10799

108-
109100
/**
110101
* Clears all received output.
111102
*/
112103
clear(): void;
104+
105+
/**
106+
* Opens the output for this channel.
107+
*/
108+
show(preserveFocus?: boolean): TPromise<IEditor>;
113109
}
114110

115111
export interface IOutputChannelRegistry {

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export class OutputService implements IOutputService {
6363
public getOutputChannel(id: string): IOutputChannel {
6464
return {
6565
append: (output: string) => this.append(id, output),
66-
clear: () => this.clearOutput(id)
66+
clear: () => this.clearOutput(id),
67+
show: (preserveFocus: boolean) => this.showOutput(id, preserveFocus)
6768
};
6869
}
6970

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

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

9495
public getChannels(): string[] {
@@ -99,24 +100,24 @@ export class OutputService implements IOutputService {
99100
return this.activeChannelId;
100101
}
101102

102-
private clearOutput(channel: string): void {
103-
this.receivedOutput[channel] = '';
103+
private clearOutput(channelId: string): void {
104+
this.receivedOutput[channelId] = '';
104105

105-
this._onOutput.fire({ channelId: channel, output: null /* indicator to clear output */ });
106+
this._onOutput.fire({ channelId: channelId, output: null /* indicator to clear output */ });
106107
}
107108

108-
public showOutput(channel: string, preserveFocus?: boolean): TPromise<IEditor> {
109+
private showOutput(channelId: string, preserveFocus?: boolean): TPromise<IEditor> {
109110
const panel = this.panelService.getActivePanel();
110-
if (this.activeChannelId === channel && panel && panel.getId() === OUTPUT_PANEL_ID) {
111+
if (this.activeChannelId === channelId && panel && panel.getId() === OUTPUT_PANEL_ID) {
111112
return TPromise.as(<OutputPanel>panel);
112113
}
113114

114-
this.activeChannelId = channel;
115+
this.activeChannelId = channelId;
115116
this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, this.activeChannelId, StorageScope.WORKSPACE);
116-
this._onActiveOutputChannel.fire(channel); // emit event that a new channel is active
117+
this._onActiveOutputChannel.fire(channelId); // emit event that a new channel is active
117118

118119
return this.panelService.openPanel(OUTPUT_PANEL_ID, !preserveFocus).then((outputPanel: OutputPanel) => {
119-
return outputPanel && outputPanel.setInput(OutputEditorInput.getInstance(this.instantiationService, channel), EditorOptions.create({ preserveFocus: preserveFocus })).
120+
return outputPanel && outputPanel.setInput(OutputEditorInput.getInstance(this.instantiationService, channelId), EditorOptions.create({ preserveFocus: preserveFocus })).
120121
then(() => outputPanel);
121122
});
122123
}

src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class ConfigureTaskRunnerAction extends Action {
182182
}
183183
let contentPromise: TPromise<string>;
184184
if (selection.autoDetect) {
185-
this.outputService.showOutput(TaskService.OutputChannelId);
185+
this.outputService.getOutputChannel(TaskService.OutputChannelId).show();
186186
const outputChannel = this.outputService.getOutputChannel(TaskService.OutputChannelId);
187187
outputChannel.append(nls.localize('ConfigureTaskRunnerAction.autoDetecting', 'Auto detecting tasks for {0}', selection.id) + '\n');
188188
let detector = new ProcessRunnerDetector(this.fileService, this.contextService, new SystemVariables(this.editorService, this.contextService));
@@ -288,7 +288,7 @@ class ShowLogAction extends AbstractTaskAction {
288288
}
289289

290290
public run(): Promise {
291-
return this.outputService.showOutput(TaskService.OutputChannelId);
291+
return this.outputService.getOutputChannel(TaskService.OutputChannelId).show();
292292
}
293293
}
294294

@@ -548,7 +548,7 @@ class TaskService extends EventEmitter implements ITaskService {
548548
if (isAffected) {
549549
const outputChannel = this.outputService.getOutputChannel(TaskService.OutputChannelId);
550550
outputChannel.append(nls.localize('TaskSystem.invalidTaskJson', 'Error: The content of the tasks.json file has syntax errors. Please correct them before executing a task.\n'));
551-
this.outputService.showOutput(TaskService.OutputChannelId, true);
551+
this.outputService.getOutputChannel(TaskService.OutputChannelId).show(true);
552552
return TPromise.wrapError({});
553553
}
554554
}
@@ -623,7 +623,7 @@ class TaskService extends EventEmitter implements ITaskService {
623623
const outputChannel = this.outputService.getOutputChannel(TaskService.OutputChannelId);
624624
outputChannel.append(line + '\n');
625625
});
626-
this.outputService.showOutput(TaskService.OutputChannelId, true);
626+
this.outputService.getOutputChannel(TaskService.OutputChannelId).show(true);
627627
}
628628
return result;
629629
}
@@ -787,7 +787,7 @@ class TaskService extends EventEmitter implements ITaskService {
787787
this.messageService.show(Severity.Error, nls.localize('TaskSystem.unknownError', 'An error has occurred while running a task. See task log for details.'));
788788
}
789789
if (showOutput) {
790-
this.outputService.showOutput(TaskService.OutputChannelId, true);
790+
this.outputService.getOutputChannel(TaskService.OutputChannelId).show(true);
791791
}
792792
}
793793
}

src/vs/workbench/parts/tasks/node/processRunnerSystem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class ProcessRunnerSystem extends EventEmitter implements ITaskSystem {
7777
this.defaultTestTaskIdentifier = parseResult.defaultTestTaskIdentifier;
7878

7979
if (!this.validationStatus.isOK()) {
80-
this.outputService.showOutput(this.outputChannelId, true);
80+
this.showOutput();
8181
}
8282
}
8383

@@ -406,7 +406,7 @@ export class ProcessRunnerSystem extends EventEmitter implements ITaskSystem {
406406
}
407407

408408
private showOutput(): void {
409-
this.outputService.showOutput(this.outputChannelId, true);
409+
this.outputService.getOutputChannel(this.outputChannelId).show(true);
410410
}
411411

412412
private clearOutput(): void {

0 commit comments

Comments
 (0)