Skip to content

Commit

Permalink
Fix #39638
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Dec 19, 2017
1 parent 40884de commit a3f0574
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/vs/workbench/parts/output/browser/media/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
background: url('clear_output_inverse.svg') center center no-repeat;
}

.monaco-workbench .output-action.open-output {
.monaco-workbench .output-action.open-file {
background: url('open_output.svg') center center no-repeat;
}

.vs-dark .monaco-workbench .output-action.open-output,
.hc-black .monaco-workbench .output-action.open-output {
.vs-dark .monaco-workbench .output-action.open-file,
.hc-black .monaco-workbench .output-action.open-file {
background: url('open_output_inverse.svg') center center no-repeat;
}

Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/parts/output/browser/outputActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ export class ClearOutputAction extends Action {
}
}

export class OpenInEditorAction extends Action {
export class OpenFileAction extends Action {

public static readonly ID = 'workbench.output.action.openInEditor';
public static readonly LABEL = nls.localize('openInEditor', "Open in Editor");
public static readonly ID = 'workbench.output.action.openFile';
public static readonly LABEL = nls.localize('openFile', "Open File");

constructor(
id: string, label: string,
@IOutputService private outputService: IOutputService
) {
super(id, label, 'output-action open-output');
super(id, label, 'output-action open-file');
}

public run(): TPromise<any> {
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/parts/output/browser/outputPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor';
import { OUTPUT_PANEL_ID, IOutputService, CONTEXT_IN_OUTPUT } from 'vs/workbench/parts/output/common/output';
import { SwitchOutputAction, SwitchOutputActionItem, ClearOutputAction, ToggleOutputScrollLockAction } from 'vs/workbench/parts/output/browser/outputActions';
import { SwitchOutputAction, SwitchOutputActionItem, ClearOutputAction, ToggleOutputScrollLockAction, OpenFileAction } from 'vs/workbench/parts/output/browser/outputActions';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
Expand Down Expand Up @@ -55,6 +55,7 @@ export class OutputPanel extends TextResourceEditor {
this.actions = [
this.instantiationService.createInstance(SwitchOutputAction),
this.instantiationService.createInstance(ClearOutputAction, ClearOutputAction.ID, ClearOutputAction.LABEL),
this.instantiationService.createInstance(OpenFileAction, OpenFileAction.ID, OpenFileAction.LABEL),
this.instantiationService.createInstance(ToggleOutputScrollLockAction, ToggleOutputScrollLockAction.ID, ToggleOutputScrollLockAction.LABEL)
];

Expand Down
25 changes: 21 additions & 4 deletions src/vs/workbench/parts/output/electron-browser/outputServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import { IWindowService } from 'vs/platform/windows/common/windows';
import { ILogService } from 'vs/platform/log/common/log';
import { binarySearch } from 'vs/base/common/arrays';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IMessageService, Severity } from 'vs/platform/message/common/message';

const OUTPUT_ACTIVE_CHANNEL_KEY = 'output.activechannel';

Expand Down Expand Up @@ -68,8 +70,9 @@ function watchOutputDirectory(outputDir: string, logService: ILogService, onChan


interface OutputChannel extends IOutputChannel {
readonly onDispose: Event<void>;
readonly file: URI;
loadModel(): TPromise<IModel>;
readonly onDispose: Event<void>;
}

abstract class AbstractFileOutputChannel extends Disposable {
Expand All @@ -81,7 +84,7 @@ abstract class AbstractFileOutputChannel extends Disposable {

protected modelUpdater: RunOnceScheduler;
protected model: IModel;
protected readonly file: URI;
readonly file: URI;
protected startOffset: number = 0;
protected endOffset: number = 0;

Expand Down Expand Up @@ -376,7 +379,8 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
@IEnvironmentService environmentService: IEnvironmentService,
@IWindowService windowService: IWindowService,
@ITelemetryService private telemetryService: ITelemetryService,
@ILogService private logService: ILogService
@ILogService private logService: ILogService,
@IMessageService private messageService: IMessageService
) {
super();
const channels = this.getChannels();
Expand Down Expand Up @@ -418,7 +422,19 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
}

showChannelInEditor(channelId: string): TPromise<void> {
return this.editorService.openEditor(this.createInput(channelId)) as TPromise;
const channel = <OutputChannel>this.getChannel(channelId);
if (channel.file) {
return this.editorService.openEditor({ resource: channel.file })
.then(editor => {
const codeEditor = editor.getControl() as ICodeEditor;
codeEditor.updateOptions({
readOnly: true
});
codeEditor.revealLine(codeEditor.getModel().getLineCount() - 1);
});
}
this.messageService.show(Severity.Info, nls.localize('noFile', "There is no file associated to this channel"));
return TPromise.as(null);
}

getChannel(id: string): IOutputChannel {
Expand Down Expand Up @@ -513,6 +529,7 @@ class BufferredOutputChannel extends Disposable implements OutputChannel {

readonly id: string;
readonly label: string;
readonly file: URI = null;
scrollLock: boolean = false;

private _onDispose: Emitter<void> = new Emitter<void>();
Expand Down

0 comments on commit a3f0574

Please sign in to comment.