提交 ec0e23bd 编写于 作者: S Sandeep Somavarapu

Fix #42402

上级 1127d67e
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#656565" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/><polygon fill="#00539C" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#C5C5C5" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/><polygon fill="#75BEFF" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/></svg>
\ No newline at end of file
...@@ -29,3 +29,12 @@ ...@@ -29,3 +29,12 @@
.hc-black .monaco-workbench .output-action.output-scroll-unlock { .hc-black .monaco-workbench .output-action.output-scroll-unlock {
background: url('output_unlock_inverse.svg') center center no-repeat; background: url('output_unlock_inverse.svg') center center no-repeat;
} }
.monaco-workbench .output-action.open-log-file {
background: url('open_log_file.svg') center center no-repeat;
}
.vs-dark .monaco-workbench .output-action.open-log-file,
.hc-black .monaco-workbench .output-action.open-log-file {
background: url('open_log_file_inverse.svg') center center no-repeat;
}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { IAction, Action } from 'vs/base/common/actions'; import { IAction, Action } from 'vs/base/common/actions';
import { IOutputService, OUTPUT_PANEL_ID, IOutputChannelRegistry, Extensions as OutputExt, IOutputChannelIdentifier } from 'vs/workbench/parts/output/common/output'; import { IOutputService, OUTPUT_PANEL_ID, IOutputChannelRegistry, Extensions as OutputExt, IOutputChannelIdentifier, COMMAND_OPEN_LOG_VIEWER } from 'vs/workbench/parts/output/common/output';
import { SelectActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { SelectActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
...@@ -18,6 +18,8 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; ...@@ -18,6 +18,8 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
import { groupBy } from 'vs/base/common/arrays'; import { groupBy } from 'vs/base/common/arrays';
import { ICommandService } from 'vs/platform/commands/common/commands';
import URI from 'vs/base/common/uri';
export class ToggleOutputAction extends TogglePanelAction { export class ToggleOutputAction extends TogglePanelAction {
...@@ -157,3 +159,35 @@ export class SwitchOutputActionItem extends SelectActionItem { ...@@ -157,3 +159,35 @@ export class SwitchOutputActionItem extends SelectActionItem {
this.setOptions(options, Math.max(0, selected), separatorIndex !== -1 ? separatorIndex : void 0); this.setOptions(options, Math.max(0, selected), separatorIndex !== -1 ? separatorIndex : void 0);
} }
} }
export class OpenLogOutputFile extends Action {
public static readonly ID = 'workbench.output.action.openLogOutputFile';
public static readonly LABEL = nls.localize('openInLogViewer', "Open Log File");
private disposables: IDisposable[] = [];
constructor(
@ICommandService private commandService: ICommandService,
@IOutputService private outputService: IOutputService
) {
super(OpenLogOutputFile.ID, OpenLogOutputFile.LABEL, 'output-action open-log-file');
this.outputService.onActiveOutputChannel(this.update, this, this.disposables);
this.update();
}
private update(): void {
const logFile = this.getActiveLogChannelFile();
this.enabled = !!logFile;
}
public run(): TPromise<any> {
return this.commandService.executeCommand(COMMAND_OPEN_LOG_VIEWER, this.getActiveLogChannelFile());
}
private getActiveLogChannelFile(): URI {
const channel = this.outputService.getActiveChannel();
const identifier = channel ? this.outputService.getChannels().filter(c => c.id === channel.id)[0] : null;
return identifier ? identifier.file : null;
}
}
...@@ -19,7 +19,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; ...@@ -19,7 +19,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor'; import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
import { AbstractTextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor'; import { AbstractTextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor';
import { OUTPUT_PANEL_ID, IOutputService, CONTEXT_IN_OUTPUT } from 'vs/workbench/parts/output/common/output'; 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, OpenLogOutputFile } from 'vs/workbench/parts/output/browser/outputActions';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
...@@ -55,7 +55,8 @@ export class OutputPanel extends AbstractTextResourceEditor { ...@@ -55,7 +55,8 @@ export class OutputPanel extends AbstractTextResourceEditor {
this.actions = [ this.actions = [
this.instantiationService.createInstance(SwitchOutputAction), this.instantiationService.createInstance(SwitchOutputAction),
this.instantiationService.createInstance(ClearOutputAction, ClearOutputAction.ID, ClearOutputAction.LABEL), this.instantiationService.createInstance(ClearOutputAction, ClearOutputAction.ID, ClearOutputAction.LABEL),
this.instantiationService.createInstance(ToggleOutputScrollLockAction, ToggleOutputScrollLockAction.ID, ToggleOutputScrollLockAction.LABEL) this.instantiationService.createInstance(ToggleOutputScrollLockAction, ToggleOutputScrollLockAction.ID, ToggleOutputScrollLockAction.LABEL),
this.instantiationService.createInstance(OpenLogOutputFile)
]; ];
this.actions.forEach(a => { this.actions.forEach(a => {
......
...@@ -61,6 +61,8 @@ export const MAX_OUTPUT_LENGTH = 10000 /* Max. number of output lines to show in ...@@ -61,6 +61,8 @@ export const MAX_OUTPUT_LENGTH = 10000 /* Max. number of output lines to show in
export const CONTEXT_IN_OUTPUT = new RawContextKey<boolean>('inOutput', false); export const CONTEXT_IN_OUTPUT = new RawContextKey<boolean>('inOutput', false);
export const CONTEXT_ACTIVE_LOG_OUTPUT = new RawContextKey<boolean>('activeLogOutput', false);
export const IOutputService = createDecorator<IOutputService>(OUTPUT_SERVICE_ID); export const IOutputService = createDecorator<IOutputService>(OUTPUT_SERVICE_ID);
/** /**
......
...@@ -12,8 +12,8 @@ import { KeybindingsRegistry, IKeybindings } from 'vs/platform/keybinding/common ...@@ -12,8 +12,8 @@ import { KeybindingsRegistry, IKeybindings } from 'vs/platform/keybinding/common
import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
import { OutputService, LogContentProvider } from 'vs/workbench/parts/output/electron-browser/outputServices'; import { OutputService, LogContentProvider } from 'vs/workbench/parts/output/electron-browser/outputServices';
import { ToggleOutputAction, ClearOutputAction } from 'vs/workbench/parts/output/browser/outputActions'; import { ToggleOutputAction, ClearOutputAction, OpenLogOutputFile } from 'vs/workbench/parts/output/browser/outputActions';
import { OUTPUT_MODE_ID, OUTPUT_MIME, OUTPUT_PANEL_ID, IOutputService, CONTEXT_IN_OUTPUT, LOG_SCHEME, COMMAND_OPEN_LOG_VIEWER, LOG_MODE_ID, LOG_MIME } from 'vs/workbench/parts/output/common/output'; import { OUTPUT_MODE_ID, OUTPUT_MIME, OUTPUT_PANEL_ID, IOutputService, CONTEXT_IN_OUTPUT, LOG_SCHEME, COMMAND_OPEN_LOG_VIEWER, LOG_MODE_ID, LOG_MIME, CONTEXT_ACTIVE_LOG_OUTPUT } from 'vs/workbench/parts/output/common/output';
import { PanelRegistry, Extensions, PanelDescriptor } from 'vs/workbench/browser/panel'; import { PanelRegistry, Extensions, PanelDescriptor } from 'vs/workbench/browser/panel';
import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands'; import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
...@@ -168,6 +168,18 @@ registerAction({ ...@@ -168,6 +168,18 @@ registerAction({
} }
}); });
registerAction({
id: 'workbench.action.openActiveLogOutputFile',
title: nls.localize('openActiveLogOutputFile', "View: Open Active Log Output File"),
menu: {
menuId: MenuId.CommandPalette,
when: CONTEXT_ACTIVE_LOG_OUTPUT
},
handler(accessor) {
accessor.get(IInstantiationService).createInstance(OpenLogOutputFile).run();
}
});
CommandsRegistry.registerCommand(COMMAND_OPEN_LOG_VIEWER, function (accessor: ServicesAccessor, file: URI) { CommandsRegistry.registerCommand(COMMAND_OPEN_LOG_VIEWER, function (accessor: ServicesAccessor, file: URI) {
if (file) { if (file) {
const editorService = accessor.get(IWorkbenchEditorService); const editorService = accessor.get(IWorkbenchEditorService);
......
...@@ -16,7 +16,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti ...@@ -16,7 +16,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
import { EditorOptions } from 'vs/workbench/common/editor'; import { EditorOptions } from 'vs/workbench/common/editor';
import { IOutputChannelIdentifier, IOutputChannel, IOutputService, Extensions, OUTPUT_PANEL_ID, IOutputChannelRegistry, OUTPUT_SCHEME, OUTPUT_MIME, MAX_OUTPUT_LENGTH, LOG_SCHEME, LOG_MIME } from 'vs/workbench/parts/output/common/output'; import { IOutputChannelIdentifier, IOutputChannel, IOutputService, Extensions, OUTPUT_PANEL_ID, IOutputChannelRegistry, OUTPUT_SCHEME, OUTPUT_MIME, MAX_OUTPUT_LENGTH, LOG_SCHEME, LOG_MIME, CONTEXT_ACTIVE_LOG_OUTPUT } from 'vs/workbench/parts/output/common/output';
import { OutputPanel } from 'vs/workbench/parts/output/browser/outputPanel'; import { OutputPanel } from 'vs/workbench/parts/output/browser/outputPanel';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IModelService } from 'vs/editor/common/services/modelService'; import { IModelService } from 'vs/editor/common/services/modelService';
...@@ -40,6 +40,7 @@ import { binarySearch } from 'vs/base/common/arrays'; ...@@ -40,6 +40,7 @@ import { binarySearch } from 'vs/base/common/arrays';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { Schemas } from 'vs/base/common/network'; import { Schemas } from 'vs/base/common/network';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
const OUTPUT_ACTIVE_CHANNEL_KEY = 'output.activechannel'; const OUTPUT_ACTIVE_CHANNEL_KEY = 'output.activechannel';
...@@ -439,6 +440,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo ...@@ -439,6 +440,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
@ITelemetryService private telemetryService: ITelemetryService, @ITelemetryService private telemetryService: ITelemetryService,
@ILogService private logService: ILogService, @ILogService private logService: ILogService,
@ILifecycleService private lifecycleService: ILifecycleService, @ILifecycleService private lifecycleService: ILifecycleService,
@IContextKeyService private contextKeyService: IContextKeyService,
) { ) {
super(); super();
this.activeChannelIdInStorage = this.storageService.get(OUTPUT_ACTIVE_CHANNEL_KEY, StorageScope.WORKSPACE, null); this.activeChannelIdInStorage = this.storageService.get(OUTPUT_ACTIVE_CHANNEL_KEY, StorageScope.WORKSPACE, null);
...@@ -510,21 +512,24 @@ export class OutputService extends Disposable implements IOutputService, ITextMo ...@@ -510,21 +512,24 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
this.channels.set(channelId, channel); this.channels.set(channelId, channel);
if (this.activeChannelIdInStorage === channelId) { if (this.activeChannelIdInStorage === channelId) {
this.activeChannel = channel; this.activeChannel = channel;
this.onDidPanelOpen(this.panelService.getActivePanel()); this.onDidPanelOpen(this.panelService.getActivePanel())
.then(() => this._onActiveOutputChannel.fire(channelId));
} }
} }
private onDidPanelOpen(panel: IPanel): void { private onDidPanelOpen(panel: IPanel): TPromise<void> {
if (panel && panel.getId() === OUTPUT_PANEL_ID) { if (panel && panel.getId() === OUTPUT_PANEL_ID) {
this._outputPanel = <OutputPanel>this.panelService.getActivePanel(); this._outputPanel = <OutputPanel>this.panelService.getActivePanel();
if (this.activeChannel) { if (this.activeChannel) {
this.doShowChannel(this.activeChannel, true); return this.doShowChannel(this.activeChannel, true);
} }
} }
return TPromise.as(null);
} }
private onDidPanelClose(panel: IPanel): void { private onDidPanelClose(panel: IPanel): void {
if (this._outputPanel && panel.getId() === OUTPUT_PANEL_ID) { if (this._outputPanel && panel.getId() === OUTPUT_PANEL_ID) {
CONTEXT_ACTIVE_LOG_OUTPUT.bindTo(this.contextKeyService).set(false);
this._outputPanel.clearInput(); this._outputPanel.clearInput();
} }
} }
...@@ -577,13 +582,17 @@ export class OutputService extends Disposable implements IOutputService, ITextMo ...@@ -577,13 +582,17 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
} }
} }
private doShowChannel(channel: IOutputChannel, preserveFocus: boolean): void { private doShowChannel(channel: IOutputChannel, preserveFocus: boolean): TPromise<void> {
if (this._outputPanel) { if (this._outputPanel) {
this._outputPanel.setInput(this.createInput(channel), EditorOptions.create({ preserveFocus: preserveFocus })); CONTEXT_ACTIVE_LOG_OUTPUT.bindTo(this.contextKeyService).set(channel instanceof FileOutputChannel);
return this._outputPanel.setInput(this.createInput(channel), EditorOptions.create({ preserveFocus: preserveFocus }))
.then(() => {
if (!preserveFocus) { if (!preserveFocus) {
this._outputPanel.focus(); this._outputPanel.focus();
} }
});
} }
return TPromise.as(null);
} }
private isChannelShown(channel: IOutputChannel): boolean { private isChannelShown(channel: IOutputChannel): boolean {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册