Skip to content

Commit 9094e49

Browse files
committed
Support logFile arg in workbench.action.openLogFile
Fixes microsoft#185338
1 parent e44d44a commit 9094e49

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/vs/workbench/contrib/output/browser/output.contribution.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,24 @@ class OutputContribution extends Disposable implements IWorkbenchContribution {
368368
menu: {
369369
id: MenuId.CommandPalette,
370370
},
371+
description: {
372+
description: 'workbench.action.openLogFile',
373+
args: [{
374+
name: 'args',
375+
schema: {
376+
type: 'object',
377+
properties: {
378+
logFile: {
379+
description: nls.localize('logFile', "The name of the log file to open, for example \"Extension Host\""),
380+
type: 'string'
381+
}
382+
}
383+
}
384+
}]
385+
},
371386
});
372387
}
373-
async run(accessor: ServicesAccessor): Promise<void> {
388+
async run(accessor: ServicesAccessor, args?: unknown): Promise<void> {
374389
const outputService = accessor.get(IOutputService);
375390
const quickInputService = accessor.get(IQuickInputService);
376391
const instantiationService = accessor.get(IInstantiationService);
@@ -379,7 +394,14 @@ class OutputContribution extends Disposable implements IWorkbenchContribution {
379394
const entries: IOutputChannelQuickPickItem[] = outputService.getChannelDescriptors().filter(c => c.file && c.log)
380395
.map(channel => (<IOutputChannelQuickPickItem>{ id: channel.id, label: channel.label, channel }));
381396

382-
const entry = await quickInputService.pick(entries, { placeHolder: nls.localize('selectlogFile', "Select Log file") });
397+
const argName = args && typeof args === 'object' && 'logFile' in args && typeof args.logFile === 'string' ? args.logFile : undefined;
398+
let entry: IOutputChannelQuickPickItem | undefined;
399+
if (argName) {
400+
entry = entries.find(e => e.label === argName);
401+
}
402+
if (!entry) {
403+
entry = await quickInputService.pick(entries, { placeHolder: nls.localize('selectlogFile', "Select Log File") });
404+
}
383405
if (entry) {
384406
assertIsDefined(entry.channel.file);
385407
await editorService.openEditor(instantiationService.createInstance(LogViewerInput, (entry.channel as IFileOutputChannelDescriptor)), { pinned: true });

0 commit comments

Comments
 (0)