Skip to content

Commit 243d2ec

Browse files
authored
Merge pull request microsoft#185341 from microsoft/tyriar/185338
Support logFile arg in workbench.action.openLogFile
2 parents 81d4fbc + 7b8eedb commit 243d2ec

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,19 @@ class OutputContribution extends Disposable implements IWorkbenchContribution {
368368
menu: {
369369
id: MenuId.CommandPalette,
370370
},
371+
description: {
372+
description: 'workbench.action.openLogFile',
373+
args: [{
374+
name: 'logFile',
375+
schema: {
376+
markdownDescription: nls.localize('logFile', "The id of the log file to open, for example `\"window\"`. Currently the best way to get this is to get the ID by checking the `workbench.action.output.show.<id>` commands"),
377+
type: 'string'
378+
}
379+
}]
380+
},
371381
});
372382
}
373-
async run(accessor: ServicesAccessor): Promise<void> {
383+
async run(accessor: ServicesAccessor, args?: unknown): Promise<void> {
374384
const outputService = accessor.get(IOutputService);
375385
const quickInputService = accessor.get(IQuickInputService);
376386
const instantiationService = accessor.get(IInstantiationService);
@@ -379,7 +389,14 @@ class OutputContribution extends Disposable implements IWorkbenchContribution {
379389
const entries: IOutputChannelQuickPickItem[] = outputService.getChannelDescriptors().filter(c => c.file && c.log)
380390
.map(channel => (<IOutputChannelQuickPickItem>{ id: channel.id, label: channel.label, channel }));
381391

382-
const entry = await quickInputService.pick(entries, { placeHolder: nls.localize('selectlogFile', "Select Log file") });
392+
const argName = args && typeof args === 'string' ? args : undefined;
393+
let entry: IOutputChannelQuickPickItem | undefined;
394+
if (argName) {
395+
entry = entries.find(e => e.id === argName);
396+
}
397+
if (!entry) {
398+
entry = await quickInputService.pick(entries, { placeHolder: nls.localize('selectlogFile', "Select Log File") });
399+
}
383400
if (entry) {
384401
assertIsDefined(entry.channel.file);
385402
await editorService.openEditor(instantiationService.createInstance(LogViewerInput, (entry.channel as IFileOutputChannelDescriptor)), { pinned: true });

0 commit comments

Comments
 (0)