提交 29509060 编写于 作者: S Sandeep Somavarapu

#18095 - Let match command's default locale label while searching in keybindings editor

上级 97373541
......@@ -398,7 +398,12 @@ class Delegate implements IDelegate<IListEntry> {
getHeight(element: IListEntry) {
if (element.templateId === KEYBINDING_ENTRY_TEMPLATE_ID) {
if ((<IKeybindingItemEntry>element).keybindingItem.commandLabel && (<IKeybindingItemEntry>element).commandIdMatches) {
const commandIdMatched = (<IKeybindingItemEntry>element).keybindingItem.commandLabel && (<IKeybindingItemEntry>element).commandIdMatches;
const commandDefaultLabelMatched = !!(<IKeybindingItemEntry>element).commandDefaultLabelMatches;
if (commandIdMatched && commandDefaultLabelMatched) {
return 60;
}
if (commandIdMatched || commandDefaultLabelMatched) {
return 40;
}
}
......@@ -542,12 +547,17 @@ class CommandColumn extends Column {
render(keybindingItemEntry: IKeybindingItemEntry): void {
DOM.clearNode(this.commandColumn);
const keybindingItem = keybindingItemEntry.keybindingItem;
DOM.toggleClass(this.commandColumn, 'command-id-label', !!keybindingItem.commandLabel && !!keybindingItemEntry.commandIdMatches);
const commandIdMatched = !!(keybindingItem.commandLabel && keybindingItemEntry.commandIdMatches);
const commandDefaultLabelMatched = !!keybindingItemEntry.commandDefaultLabelMatches;
DOM.toggleClass(this.commandColumn, 'vertical-align-column', commandIdMatched || commandDefaultLabelMatched);
if (keybindingItem.commandLabel) {
const commandLabel = new HighlightedLabel(this.commandColumn);
commandLabel.set(keybindingItem.commandLabel, keybindingItemEntry.commandLabelMatches);
commandLabel.element.title = keybindingItem.command;
}
if (keybindingItemEntry.commandDefaultLabelMatches) {
new HighlightedLabel(DOM.append(this.commandColumn, $('.command-default-label'))).set(keybindingItem.commandDefaultLabel, keybindingItemEntry.commandDefaultLabelMatches);
}
if (keybindingItemEntry.commandIdMatches || !keybindingItem.commandLabel) {
new HighlightedLabel(DOM.append(this.commandColumn, $('.code'))).set(keybindingItem.command, keybindingItemEntry.commandIdMatches);
}
......
......@@ -96,9 +96,15 @@
flex: 1;
}
.keybindings-editor > .keybindings-body > .keybindings-list-container .monaco-list-row .command-id-label {
.keybindings-editor > .keybindings-body > .keybindings-list-container .monaco-list-row .command.vertical-align-column {
flex-direction: column;
align-items: flex-start;
justify-content: center;
}
.keybindings-editor > .keybindings-body > .keybindings-list-container .monaco-list-row .command .command-default-label {
opacity: 0.8;
margin-top: 2px;
}
.keybindings-editor > .keybindings-body > .keybindings-list-container .monaco-list-row .keybinding {
......
......@@ -5,6 +5,7 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { distinct } from 'vs/base/common/arrays';
import { language, LANGUAGE_DEFAULT } from 'vs/base/common/platform';
import { IMatch, IFilter, or, matchesContiguousSubString, matchesPrefix, matchesCamelCase, matchesWords } from 'vs/base/common/filters';
import { Registry } from 'vs/platform/platform';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
......@@ -29,6 +30,7 @@ export interface IKeybindingItemEntry extends IListEntry {
keybindingItem: IKeybindingItem;
commandIdMatches?: IMatch[];
commandLabelMatches?: IMatch[];
commandDefaultLabelMatches?: IMatch[];
keybindingMatches?: IMatch[];
}
......@@ -36,6 +38,7 @@ export interface IKeybindingItem {
keybinding: ResolvedKeybinding;
keybindingItem: ResolvedKeybindingItem;
commandLabel: string;
commandDefaultLabel: string;
command: string;
source: KeybindingSource;
when: ContextKeyExpr;
......@@ -64,11 +67,12 @@ export class KeybindingsEditorModel extends EditorModel {
const result: IKeybindingItemEntry[] = [];
for (const keybindingItem of this._keybindingItems) {
let keybindingMatches = new KeybindingMatches(keybindingItem, searchValue);
if (keybindingMatches.commandIdMatches || keybindingMatches.commandLabelMatches || keybindingMatches.keybindingMatches) {
if (keybindingMatches.commandIdMatches || keybindingMatches.commandLabelMatches || keybindingMatches.commandDefaultLabelMatches || keybindingMatches.keybindingMatches) {
result.push({
id: KeybindingsEditorModel.getId(keybindingItem),
templateId: KEYBINDING_ENTRY_TEMPLATE_ID,
commandLabelMatches: keybindingMatches.commandLabelMatches,
commandDefaultLabelMatches: keybindingMatches.commandDefaultLabelMatches,
keybindingItem,
keybindingMatches: keybindingMatches.keybindingMatches,
commandIdMatches: keybindingMatches.commandIdMatches
......@@ -134,12 +138,14 @@ export class KeybindingsEditorModel extends EditorModel {
private static toKeybindingEntry(keybinding: ResolvedKeybindingItem, workbenchActionsRegistry: IWorkbenchActionRegistry, editorActions: {}): IKeybindingItem {
const workbenchAction = workbenchActionsRegistry.getWorkbenchAction(keybinding.command);
const commandDefaultLabel = workbenchAction && language !== LANGUAGE_DEFAULT ? workbenchActionsRegistry.getAlias(workbenchAction.id) : null;
const editorAction: EditorAction = editorActions[keybinding.command];
return <IKeybindingItem>{
keybinding: keybinding.resolvedKeybinding,
keybindingItem: keybinding,
command: keybinding.command,
commandLabel: editorAction ? editorAction.label : workbenchAction ? workbenchAction.label : '',
commandDefaultLabel,
when: keybinding.when,
source: keybinding.isDefault ? KeybindingSource.Default : KeybindingSource.User
};
......@@ -147,12 +153,14 @@ export class KeybindingsEditorModel extends EditorModel {
private static toUnassingedKeybindingEntry(command: string, workbenchActionsRegistry: IWorkbenchActionRegistry, editorActions: {}): IKeybindingItem {
const workbenchAction = workbenchActionsRegistry.getWorkbenchAction(command);
const commandDefaultLabel = workbenchAction && language !== LANGUAGE_DEFAULT ? workbenchActionsRegistry.getAlias(workbenchAction.id) : null;
const editorAction: EditorAction = editorActions[command];
return <IKeybindingItem>{
keybinding: null,
keybindingItem: new ResolvedKeybindingItem(null, command, null, null, true),
command: command,
command,
commandLabel: editorAction ? editorAction.label : workbenchAction ? workbenchAction.label : '',
commandDefaultLabel,
when: null,
source: KeybindingSource.Default
};
......@@ -162,11 +170,13 @@ export class KeybindingsEditorModel extends EditorModel {
class KeybindingMatches {
public readonly commandIdMatches: IMatch[] = null;
public readonly commandLabelMatches: IMatch[] = null;
public readonly commandDefaultLabelMatches: IMatch[] = null;
public readonly keybindingMatches: IMatch[] = null;
constructor(keybindingItem: IKeybindingItem, searchValue: string) {
this.commandIdMatches = this.matches(searchValue, keybindingItem.command, or(matchesWords, matchesCamelCase));
this.commandLabelMatches = keybindingItem.commandLabel ? this.matches(searchValue, keybindingItem.commandLabel, (word, wordToMatchAgainst) => matchesWords(word, keybindingItem.commandLabel, true)) : null;
this.commandDefaultLabelMatches = keybindingItem.commandDefaultLabel ? this.matches(searchValue, keybindingItem.commandDefaultLabel, (word, wordToMatchAgainst) => matchesWords(word, keybindingItem.commandDefaultLabel, true)) : null;
this.keybindingMatches = keybindingItem.keybinding ? this.keyMatches(searchValue, keybindingItem.keybinding.getAriaLabel(), or(matchesWords, matchesCamelCase)) : null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册