Skip to content

Commit

Permalink
core: Allow customizing CommandQuickOpenItem
Browse files Browse the repository at this point in the history
Signed-off-by: Shahar Harari <shahar.harari@sap.com>
  • Loading branch information
shahar-h authored and kittaakos committed Oct 21, 2020
1 parent aeb85a4 commit 60def53
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/core/src/browser/quick-open/quick-command-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

import { inject, injectable } from 'inversify';
import { Command, CommandRegistry, Disposable } from '../../common';
import { Keybinding, KeybindingRegistry } from '../keybinding';
import { QuickOpenModel, QuickOpenItem, QuickOpenMode, QuickOpenGroupItem, QuickOpenGroupItemOptions } from './quick-open-model';
import { Keybinding } from '../../common/keybinding';
import { KeybindingRegistry } from '../keybinding';
import { QuickOpenModel, QuickOpenItem, QuickOpenGroupItemOptions, QuickOpenMode, QuickOpenGroupItem } from '../../common/quick-open-model';
import { QuickOpenOptions } from './quick-open-service';
import { QuickOpenContribution, QuickOpenHandlerRegistry, QuickOpenHandler } from './prefix-quick-open-service';
import { ContextKeyService } from '../context-key-service';
Expand Down Expand Up @@ -70,21 +71,17 @@ export class QuickCommandService implements QuickOpenModel, QuickOpenHandler {
const { recent, other } = this.getCommands();
this.items.push(
...recent.map((command, index) =>
new CommandQuickOpenItem(
this.createCommandQuickOpenItem(
command,
this.commands,
this.keybindings,
{
groupLabel: index === 0 ? 'recently used' : '',
showBorder: false,
}
)
),
...other.map((command, index) =>
new CommandQuickOpenItem(
this.createCommandQuickOpenItem(
command,
this.commands,
this.keybindings,
{
groupLabel: recent.length > 0 && index === 0 ? 'other commands' : '',
showBorder: recent.length > 0 && index === 0 ? true : false,
Expand All @@ -94,6 +91,10 @@ export class QuickCommandService implements QuickOpenModel, QuickOpenHandler {
);
}

protected createCommandQuickOpenItem(command: Command, commandOptions?: QuickOpenGroupItemOptions | undefined): CommandQuickOpenItem {
return new CommandQuickOpenItem(command, this.commands, this.keybindings, commandOptions);
}

public onType(lookFor: string, acceptor: (items: QuickOpenItem[]) => void): void {
acceptor(this.items);
}
Expand Down

0 comments on commit 60def53

Please sign in to comment.