提交 9b9030d5 编写于 作者: S Sandeep Somavarapu

Fix #30177

上级 bf410d4c
......@@ -25,7 +25,7 @@ import { IKeybindingService, IUserFriendlyKeybinding } from 'vs/platform/keybind
import { SearchWidget } from 'vs/workbench/parts/preferences/browser/preferencesWidgets';
import { DefineKeybindingWidget } from 'vs/workbench/parts/preferences/browser/keybindingWidgets';
import {
IPreferencesService, IKeybindingsEditor, CONTEXT_KEYBINDING_FOCUS, CONTEXT_KEYBINDINGS_EDITOR, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_COPY,
IPreferencesService, IKeybindingsEditor, CONTEXT_KEYBINDING_FOCUS, CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_COPY,
KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS
} from 'vs/workbench/parts/preferences/common/preferences';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
......@@ -94,6 +94,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
private delayedFilterLogging: Delayer<void>;
private keybindingsEditorContextKey: IContextKey<boolean>;
private keybindingFocusContextKey: IContextKey<boolean>;
private searchFocusContextKey: IContextKey<boolean>;
private sortByPrecedence: Checkbox;
constructor(
......@@ -116,6 +117,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
this._register(keybindingsService.onDidUpdateKeybindings(() => this.render()));
this.keybindingsEditorContextKey = CONTEXT_KEYBINDINGS_EDITOR.bindTo(this.contextKeyService);
this.searchFocusContextKey = CONTEXT_KEYBINDINGS_SEARCH_FOCUS.bindTo(this.contextKeyService);
this.keybindingFocusContextKey = CONTEXT_KEYBINDING_FOCUS.bindTo(this.contextKeyService);
this.delayedFilterLogging = new Delayer<void>(1000);
}
......@@ -280,10 +282,9 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
this.searchWidget = this._register(this.instantiationService.createInstance(SearchWidget, searchContainer, {
ariaLabel: localize('SearchKeybindings.AriaLabel', "Search keybindings"),
placeholder: localize('SearchKeybindings.Placeholder', "Search keybindings"),
navigateByArrows: true
focusKey: this.searchFocusContextKey
}));
this._register(this.searchWidget.onDidChange(searchValue => this.delayedFiltering.trigger(() => this.filterKeybindings())));
this._register(this.searchWidget.onNavigate(back => this._onNavigate(back)));
this.sortByPrecedence = this._register(new Checkbox({
actionClassName: 'sort-by-precedence',
......@@ -426,12 +427,10 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
}
}
private _onNavigate(back: boolean): void {
if (!back) {
this.keybindingsList.getHTMLElement().focus();
const currentFocusIndices = this.keybindingsList.getFocus();
this.keybindingsList.setFocus([currentFocusIndices.length ? currentFocusIndices[0] : 0]);
}
focusKeybindings(): void {
this.keybindingsList.getHTMLElement().focus();
const currentFocusIndices = this.keybindingsList.getFocus();
this.keybindingsList.setFocus([currentFocusIndices.length ? currentFocusIndices[0] : 0]);
}
private onContextMenu(e: IListContextMenuEvent<IListEntry>): void {
......
......@@ -19,8 +19,8 @@ import { DefaultPreferencesEditorInput, PreferencesEditor, PreferencesEditorInpu
import { KeybindingsEditor, KeybindingsEditorInput } from 'vs/workbench/parts/preferences/browser/keybindingsEditor';
import { OpenGlobalSettingsAction, OpenGlobalKeybindingsAction, OpenGlobalKeybindingsFileAction, OpenWorkspaceSettingsAction, ConfigureLanguageBasedSettingsAction } from 'vs/workbench/parts/preferences/browser/preferencesActions';
import {
IPreferencesService, IKeybindingsEditor, CONTEXT_KEYBINDING_FOCUS, CONTEXT_KEYBINDINGS_EDITOR, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_SEARCH,
KEYBINDINGS_EDITOR_COMMAND_COPY, KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS
IPreferencesService, IKeybindingsEditor, CONTEXT_KEYBINDING_FOCUS, CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_SEARCH,
KEYBINDINGS_EDITOR_COMMAND_COPY, KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS, KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS
} from 'vs/workbench/parts/preferences/common/preferences';
import { PreferencesService } from 'vs/workbench/parts/preferences/browser/preferencesService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -234,4 +234,15 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS),
primary: KeyCode.DownArrow,
handler: (accessor, args: any) => {
const editor = accessor.get(IWorkbenchEditorService).getActiveEditor() as IKeybindingsEditor;
editor.focusKeybindings();
}
});
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(PreferencesContentProvider);
\ No newline at end of file
......@@ -288,8 +288,6 @@ export class SettingsTabsWidget extends Widget {
}
export interface SearchOptions extends IInputOptions {
navigateByEnter?: boolean;
navigateByArrows?: boolean;
focusKey?: IContextKey<boolean>;
}
......@@ -408,10 +406,8 @@ export class SearchWidget extends Widget {
let handled = false;
switch (keyboardEvent.keyCode) {
case KeyCode.Enter:
if (this.options.navigateByEnter) {
this._onNavigate.fire(keyboardEvent.shiftKey);
handled = true;
}
this._onNavigate.fire(keyboardEvent.shiftKey);
handled = true;
break;
case KeyCode.Escape:
this.clear();
......
......@@ -86,6 +86,7 @@ export interface IKeybindingsEditor extends IEditor {
activeKeybindingEntry: IKeybindingItemEntry;
search(filter: string): void;
focusKeybindings(): void;
defineKeybinding(keybindingEntry: IKeybindingItemEntry): TPromise<any>;
removeKeybinding(keybindingEntry: IKeybindingItemEntry): TPromise<any>;
resetKeybinding(keybindingEntry: IKeybindingItemEntry): TPromise<any>;
......@@ -96,6 +97,7 @@ export interface IKeybindingsEditor extends IEditor {
export const CONTEXT_SETTINGS_EDITOR = new RawContextKey<boolean>('inSettingsEditor', false);
export const CONTEXT_SETTINGS_SEARCH_FOCUS = new RawContextKey<boolean>('inSettingsSearch', false);
export const CONTEXT_KEYBINDINGS_EDITOR = new RawContextKey<boolean>('inKeybindings', false);
export const CONTEXT_KEYBINDINGS_SEARCH_FOCUS = new RawContextKey<boolean>('inKeybindingsSearch', false);
export const CONTEXT_KEYBINDING_FOCUS = new RawContextKey<boolean>('keybindingFocus', false);
export const SETTINGS_EDITOR_COMMAND_SEARCH = 'settings.action.search';
......@@ -105,4 +107,5 @@ export const KEYBINDINGS_EDITOR_COMMAND_DEFINE = 'keybindings.editor.defineKeybi
export const KEYBINDINGS_EDITOR_COMMAND_REMOVE = 'keybindings.editor.removeKeybinding';
export const KEYBINDINGS_EDITOR_COMMAND_RESET = 'keybindings.editor.resetKeybinding';
export const KEYBINDINGS_EDITOR_COMMAND_COPY = 'keybindings.editor.copyKeybindingEntry';
export const KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS = 'keybindings.editor.showConflicts';
\ No newline at end of file
export const KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS = 'keybindings.editor.showConflicts';
export const KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS = 'keybindings.editor.focusKeybindings';
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册