Skip to content

Commit

Permalink
fix some command palette sorting issues (#20928, #20888, #20553)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Feb 20, 2017
1 parent aaf129f commit 2fbfb7b
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/vs/workbench/parts/quickopen/browser/commandsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import types = require('vs/base/common/types');
import { language, LANGUAGE_DEFAULT } from 'vs/base/common/platform';
import { IAction, Action } from 'vs/base/common/actions';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import strings = require('vs/base/common/strings');
import { Mode, IEntryRunContext, IAutoFocus } from 'vs/base/parts/quickopen/common/quickOpen';
import { QuickOpenEntryGroup, IHighlight, QuickOpenModel, QuickOpenEntry } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { QuickOpenEntryGroup, IHighlight, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { SyncActionDescriptor, IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry';
Expand Down Expand Up @@ -233,7 +232,6 @@ class ActionCommandEntry extends BaseCommandEntry {
}

export class CommandsHandler extends QuickOpenHandler {
private scorerCache: { [key: string]: number };

constructor(
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
Expand All @@ -243,8 +241,6 @@ export class CommandsHandler extends QuickOpenHandler {
@IContextKeyService private contextKeyService: IContextKeyService
) {
super();

this.scorerCache = Object.create(null);
}

protected includeWorkbenchCommands(): boolean {
Expand Down Expand Up @@ -291,8 +287,7 @@ export class CommandsHandler extends QuickOpenHandler {

// Sort
if (searchValue) {
const normalizedSearchValue = strings.stripWildcards(searchValue).toLowerCase();
entries = entries.sort((elementA, elementB) => QuickOpenEntry.compareByScore(elementA, elementB, searchValue, normalizedSearchValue, this.scorerCache));
entries = entries.sort((elementA, elementB) => elementA.getLabel().length - elementB.getLabel().length);
} else {
entries = entries.sort((elementA, elementB) => elementA.getLabel().toLowerCase().localeCompare(elementB.getLabel().toLowerCase()));
}
Expand Down Expand Up @@ -392,12 +387,6 @@ export class CommandsHandler extends QuickOpenHandler {
public getEmptyLabel(searchString: string): string {
return nls.localize('noCommandsMatching', "No commands matching");
}

public onClose(canceled: boolean): void {

// Clear Cache
this.scorerCache = Object.create(null);
}
}

export class EditorCommandsHandler extends CommandsHandler {
Expand Down

0 comments on commit 2fbfb7b

Please sign in to comment.