export class CommandMenu{constructor(){this._commands=[];this._loadCommands();} static createCommand(category,keys,title,shortcut,executeHandler,availableHandler){const keyList=keys.split(',');let key='';keyList.forEach(k=>{key+=(ls(k.trim())+'\0');});return new Command(category,title,key,shortcut,executeHandler,availableHandler);} static createSettingCommand(extension,title,value){const category=extension.descriptor()['category']||'';const tags=extension.descriptor()['tags']||'';const setting=Common.settings.moduleSetting(extension.descriptor()['settingName']);return QuickOpen.CommandMenu.createCommand(ls(category),tags,title,'',setting.set.bind(setting,value),availableHandler);function availableHandler(){return setting.get()!==value;}} static createActionCommand(action){const shortcut=UI.shortcutRegistry.shortcutTitleForAction(action.id())||'';return QuickOpen.CommandMenu.createCommand(action.category(),action.tags(),action.title(),shortcut,action.execute.bind(action));} static createRevealViewCommand(extension,category){const viewId=extension.descriptor()['id'];const executeHandler=UI.viewManager.showView.bind(UI.viewManager,viewId);const tags=extension.descriptor()['tags']||'';return QuickOpen.CommandMenu.createCommand(category,tags,Common.UIString('Show %s',extension.title()),'',executeHandler);} _loadCommands(){const locations=new Map();self.runtime.extensions(UI.ViewLocationResolver).forEach(extension=>{const category=extension.descriptor()['category'];const name=extension.descriptor()['name'];if(category&&name){locations.set(name,category);}});const viewExtensions=self.runtime.extensions('view');for(const extension of viewExtensions){const category=locations.get(extension.descriptor()['location']);if(category){this._commands.push(QuickOpen.CommandMenu.createRevealViewCommand(extension,ls(category)));}} const settingExtensions=self.runtime.extensions('setting');for(const extension of settingExtensions){const options=extension.descriptor()['options'];if(!options||!extension.descriptor()['category']){continue;} for(const pair of options){this._commands.push(QuickOpen.CommandMenu.createSettingCommand(extension,ls(pair['title']),pair['value']));}}} commands(){return this._commands;}} export class CommandMenuProvider extends QuickOpen.FilteredListWidget.Provider{constructor(){super();this._commands=[];} attach(){const allCommands=commandMenu.commands();const actions=UI.actionRegistry.availableActions();for(const action of actions){if(action.category()){this._commands.push(QuickOpen.CommandMenu.createActionCommand(action));}} for(const command of allCommands){if(command.available()){this._commands.push(command);}} this._commands=this._commands.sort(commandComparator);function commandComparator(left,right){const cats=left.category().compareTo(right.category());return cats?cats:left.title().compareTo(right.title());}} detach(){this._commands=[];} itemCount(){return this._commands.length;} itemKeyAt(itemIndex){return this._commands[itemIndex].key();} itemScoreAt(itemIndex,query){const command=this._commands[itemIndex];const opcodes=Diff.Diff.charDiff(query.toLowerCase(),command.title().toLowerCase());let score=0;for(let i=0;i');return true;}} self.QuickOpen=self.QuickOpen||{};QuickOpen=QuickOpen||{};QuickOpen.CommandMenu=CommandMenu;QuickOpen.CommandMenu.Command=Command;QuickOpen.CommandMenu.ShowActionDelegate=ShowActionDelegate;QuickOpen.CommandMenuProvider=CommandMenuProvider;QuickOpen.CommandMenuProvider.MaterialPaletteColors=MaterialPaletteColors;const commandMenu=new CommandMenu();QuickOpen.commandMenu=commandMenu;