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

Fix #51303

上级 2fb8c99a
......@@ -247,8 +247,12 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
return TPromise.as(null);
}
search(filter: string): void {
focusSearch(): void {
this.searchWidget.focus();
}
search(filter: string): void {
this.focusSearch();
this.searchWidget.setValue(filter);
}
......
......@@ -48,6 +48,7 @@ export interface IKeybindingsEditor extends IEditor {
activeKeybindingEntry: IKeybindingItemEntry;
search(filter: string): void;
focusSearch(): void;
clearSearchResults(): void;
focusKeybindings(): void;
defineKeybinding(keybindingEntry: IKeybindingItemEntry): TPromise<any>;
......
......@@ -239,7 +239,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS),
primary: KeyMod.CtrlCmd | KeyCode.KEY_F,
handler: (accessor, args: any) => (accessor.get(IEditorService).activeControl as IKeybindingsEditor).search('')
handler: (accessor, args: any) => (accessor.get(IEditorService).activeControl as IKeybindingsEditor).focusSearch()
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
......
......@@ -160,8 +160,8 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
const { tabSize, insertSpaces } = model.getOptions();
const eol = model.getEOL();
const userKeybindingEntries = <IUserFriendlyKeybinding[]>json.parse(model.getValue());
const index = this.findUnassignedDefaultKeybindingEntryIndex(keybindingItem, userKeybindingEntries);
if (index !== -1) {
const indices = this.findUnassignedDefaultKeybindingEntryIndex(keybindingItem, userKeybindingEntries).reverse();
for (const index of indices) {
this.applyEditsToBuffer(setProperty(model.getValue(), [index], void 0, { tabSize, insertSpaces, eol })[0], model);
}
}
......@@ -183,13 +183,14 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
return -1;
}
private findUnassignedDefaultKeybindingEntryIndex(keybindingItem: ResolvedKeybindingItem, userKeybindingEntries: IUserFriendlyKeybinding[]): number {
private findUnassignedDefaultKeybindingEntryIndex(keybindingItem: ResolvedKeybindingItem, userKeybindingEntries: IUserFriendlyKeybinding[]): number[] {
const indices = [];
for (let index = 0; index < userKeybindingEntries.length; index++) {
if (userKeybindingEntries[index].command === `-${keybindingItem.command}`) {
return index;
indices.push(index);
}
}
return -1;
return indices;
}
private asObject(key: string, command: string, when: ContextKeyExpr, negate: boolean): any {
......
......@@ -55,7 +55,7 @@ interface Modifiers {
shiftKey?: boolean;
}
suite('Keybindings Editing', () => {
suite('KeybindingsEditing', () => {
let instantiationService: TestInstantiationService;
let testObject: KeybindingsEditingService;
......@@ -220,6 +220,14 @@ suite('Keybindings Editing', () => {
.then(() => assert.deepEqual(getUserKeybindings(), []));
});
test('reset mulitple removed keybindings', () => {
writeToKeybindingsFile({ key: 'alt+c', command: '-b' });
writeToKeybindingsFile({ key: 'alt+shift+c', command: '-b' });
writeToKeybindingsFile({ key: 'escape', command: '-b' });
return testObject.resetKeybinding(aResolvedKeybindingItem({ command: 'b', isDefault: false }))
.then(() => assert.deepEqual(getUserKeybindings(), []));
});
function writeToKeybindingsFile(...keybindings: IUserFriendlyKeybinding[]) {
fs.writeFileSync(keybindingsFile, JSON.stringify(keybindings || []));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册