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

Make open log file action independent of schema

上级 b3ae3bd0
......@@ -17,7 +17,7 @@ import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorIn
import { URI } from 'vs/base/common/uri';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
import { LOG_SCHEME } from 'vs/workbench/parts/output/common/output';
import { LOG_SCHEME, IOutputChannelDescriptor } from 'vs/workbench/parts/output/common/output';
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IWindowService } from 'vs/platform/windows/common/windows';
......@@ -26,11 +26,11 @@ export class LogViewerInput extends ResourceEditorInput {
public static readonly ID = 'workbench.editorinputs.output';
constructor(private file: URI,
constructor(private outputChannelDescriptor: IOutputChannelDescriptor,
@ITextModelService textModelResolverService: ITextModelService,
@IHashService hashService: IHashService
) {
super(paths.basename(file.fsPath), paths.dirname(file.fsPath), file.with({ scheme: LOG_SCHEME }), textModelResolverService, hashService);
super(paths.basename(outputChannelDescriptor.file.path), paths.dirname(outputChannelDescriptor.file.path), URI.from({ scheme: LOG_SCHEME, path: outputChannelDescriptor.id }), textModelResolverService, hashService);
}
public getTypeId(): string {
......@@ -38,7 +38,7 @@ export class LogViewerInput extends ResourceEditorInput {
}
public getResource(): URI {
return this.file;
return this.outputChannelDescriptor.file;
}
}
......
......@@ -20,7 +20,6 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView
import { Registry } from 'vs/platform/registry/common/platform';
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 {
......@@ -180,16 +179,16 @@ export class OpenLogOutputFile extends Action {
}
private update(): void {
this.enabled = !!this.getLogFile();
const outputChannelDescriptor = this.getOutputChannelDescriptor();
this.enabled = outputChannelDescriptor && outputChannelDescriptor.file && outputChannelDescriptor.log;
}
public run(): TPromise<any> {
return this.commandService.executeCommand(COMMAND_OPEN_LOG_VIEWER, this.getLogFile());
return this.enabled ? this.commandService.executeCommand(COMMAND_OPEN_LOG_VIEWER, this.getOutputChannelDescriptor()) : TPromise.as(null);
}
private getLogFile(): URI {
private getOutputChannelDescriptor(): IOutputChannelDescriptor {
const channel = this.outputService.getActiveChannel();
const descriptor = channel ? this.outputService.getChannelDescriptors().filter(c => c.id === channel.id)[0] : null;
return descriptor && descriptor.log ? descriptor.file : null;
return channel ? this.outputService.getChannelDescriptors().filter(c => c.id === channel.id)[0] : null;
}
}
......@@ -13,7 +13,7 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
import { OutputService, LogContentProvider } from 'vs/workbench/parts/output/electron-browser/outputServices';
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, CONTEXT_ACTIVE_LOG_OUTPUT } 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, IOutputChannelDescriptor } from 'vs/workbench/parts/output/common/output';
import { PanelRegistry, Extensions, PanelDescriptor } from 'vs/workbench/browser/panel';
import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
......@@ -25,7 +25,6 @@ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWo
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { URI } from 'vs/base/common/uri';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
// Register Service
......@@ -180,10 +179,10 @@ registerAction({
}
});
CommandsRegistry.registerCommand(COMMAND_OPEN_LOG_VIEWER, function (accessor: ServicesAccessor, file: URI) {
if (file) {
CommandsRegistry.registerCommand(COMMAND_OPEN_LOG_VIEWER, function (accessor: ServicesAccessor, outputChannelDescriptor: IOutputChannelDescriptor) {
if (outputChannelDescriptor && outputChannelDescriptor.file) {
const editorService = accessor.get(IEditorService);
return editorService.openEditor(accessor.get(IInstantiationService).createInstance(LogViewerInput, file));
return editorService.openEditor(accessor.get(IInstantiationService).createInstance(LogViewerInput, outputChannelDescriptor));
}
return null;
});
......
......@@ -34,7 +34,6 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { toLocalISOString } from 'vs/base/common/date';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { ILogService } from 'vs/platform/log/common/log';
import { Schemas } from 'vs/base/common/network';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { CancellationToken } from 'vs/base/common/cancellation';
......@@ -591,6 +590,7 @@ export class LogContentProvider {
private channels: Map<string, OutputChannel> = new Map<string, OutputChannel>();
constructor(
@IOutputService private outputService: IOutputService,
@IInstantiationService private instantiationService: IInstantiationService
) {
}
......@@ -606,13 +606,16 @@ export class LogContentProvider {
}
private getChannel(resource: URI): OutputChannel {
const id = resource.path;
let channel = this.channels.get(id);
const channelId = resource.path;
let channel = this.channels.get(channelId);
if (!channel) {
const channelDisposables: IDisposable[] = [];
channel = this.instantiationService.createInstance(FileOutputChannel, { id, label: '', file: resource.with({ scheme: Schemas.file }), log: true }, resource);
channel.onDispose(() => dispose(channelDisposables), channelDisposables);
this.channels.set(id, channel);
const outputChannelDescriptor = this.outputService.getChannelDescriptors().filter(({ id }) => id === channelId)[0];
if (outputChannelDescriptor && outputChannelDescriptor.file) {
channel = this.instantiationService.createInstance(FileOutputChannel, outputChannelDescriptor, resource);
channel.onDispose(() => dispose(channelDisposables), channelDisposables);
this.channels.set(channelId, channel);
}
}
return channel;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册