diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts index a1f8281ecab8712c11ddf3a2f5d4da7df2e52ac0..72ad07faeac7ed71d8606a428853fb1ab48dd3af 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts @@ -281,6 +281,7 @@ export class ExtensionEditor extends BaseEditor { const content = append(this.content, $('div', { class: 'subcontent' })); ExtensionEditor.renderSettings(content, manifest); + ExtensionEditor.renderCommands(content, manifest); ExtensionEditor.renderThemes(content, manifest); ExtensionEditor.renderJSONValidation(content, manifest); ExtensionEditor.renderDebuggers(content, manifest); @@ -351,6 +352,57 @@ export class ExtensionEditor extends BaseEditor { )); } + private static renderCommands(container: HTMLElement, manifest: IExtensionManifest): void { + interface Command { + id: string; + title: string; + menus: string[]; + } + + const commands: Command[] = (manifest.contributes.commands || []).map(c => ({ + id: c.command, + title: c.title, + menus: [] + })); + + const allCommands = commands.reduce<{ [id: string]: Command }>((r, c) => { r[c.id] = c; return r; }, {}); + + const menus = manifest.contributes.menus || {}; + Object.keys(menus).forEach(context => { + menus[context].forEach(menu => { + let command = allCommands[menu.command]; + + if (!command) { + command = { id: menu.command, title: '', menus: [context] }; + allCommands[command.id] = command; + commands.push(command); + } else { + command.menus.push(context); + } + }); + }); + + if (!commands.length) { + return; + } + + append(container, $('details', { open: true }, + $('summary', null, localize('commands', "Commands ({0})", commands.length)), + $('table', null, + $('tr', null, + $('th', null, localize('command name', "Name")), + $('th', null, localize('description', "Description")), + $('th', null, localize('menuContexts', "Menu Contexts")) + ), + ...commands.map(c => $('tr', null, + $('td', null, c.id), + $('td', null, c.title), + $('td', null, ...c.menus.map(context => $('code', null, context))) + )) + ) + )); + } + private loadContents(loadingTask: ()=>TPromise): void { this.contentDisposables = dispose(this.contentDisposables);