提交 2ca50c08 编写于 作者: S Sandeep Somavarapu

Fix #31146

上级 9b6cc9f7
......@@ -57,6 +57,7 @@ import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRe
import { attachStylerCallback } from 'vs/platform/theme/common/styler';
import { scrollbarShadow } from 'vs/platform/theme/common/colorRegistry';
import { IWorkspaceContextService } from "vs/platform/workspace/common/workspace";
import Event, { Emitter } from "vs/base/common/event";
export class PreferencesEditorInput extends SideBySideEditorInput {
public static ID: string = 'workbench.editorinputs.preferencesEditorInput';
......@@ -112,6 +113,7 @@ export class PreferencesEditor extends BaseEditor {
private delayedFilterLogging: Delayer<void>;
private latestEmptyFilters: string[] = [];
private lastFocusedWidget: SearchWidget | SideBySidePreferencesWidget = null;
constructor(
@IPreferencesService private preferencesService: IPreferencesService,
......@@ -142,12 +144,16 @@ export class PreferencesEditor extends BaseEditor {
}));
this._register(this.searchWidget.onDidChange(value => this.filterPreferences(value.trim())));
this._register(this.searchWidget.onNavigate(shift => this.preferencesRenderers.focusNextPreference(!shift)));
this._register(this.searchWidget.onFocus(() => this.lastFocusedWidget = this.searchWidget));
this.lastFocusedWidget = this.searchWidget;
this.settingsTargetsWidget = this._register(this.instantiationService.createInstance(SettingsTargetsWidget, this.headerContainer, this.preferencesService.userSettingsResource));
this._register(this.settingsTargetsWidget.onDidTargetChange(target => this.switchSettings(target)));
const editorsContainer = DOM.append(parentElement, DOM.$('.preferences-editors-container'));
this.sideBySidePreferencesWidget = this._register(this.instantiationService.createInstance(SideBySidePreferencesWidget, editorsContainer));
this._register(this.sideBySidePreferencesWidget.onFocus(() => this.lastFocusedWidget = this.sideBySidePreferencesWidget));
this.preferencesRenderers = this._register(new PreferencesRenderers());
}
......@@ -169,7 +175,9 @@ export class PreferencesEditor extends BaseEditor {
}
public focus(): void {
this.searchWidget.focus();
if (this.lastFocusedWidget) {
this.lastFocusedWidget.focus();
}
}
public focusSearch(filter?: string): void {
......@@ -405,10 +413,15 @@ class SideBySidePreferencesWidget extends Widget {
private dimension: Dimension;
private defaultPreferencesEditor: DefaultPreferencesEditor;
private editablePreferencesEditor: EditableSettingsEditor;
private defaultPreferencesEditorContainer: HTMLElement;
private editablePreferencesEditor: BaseEditor;
private editablePreferencesEditorContainer: HTMLElement;
private _onFocus: Emitter<void> = new Emitter<void>();
readonly onFocus: Event<void> = this._onFocus.event;
private lastFocusedEditor: BaseEditor;
private sash: VSash;
constructor(parent: HTMLElement, @IInstantiationService private instantiationService: IInstantiationService, @IThemeService private themeService: IThemeService) {
......@@ -425,12 +438,15 @@ class SideBySidePreferencesWidget extends Widget {
this.defaultPreferencesEditor = this._register(this.instantiationService.createInstance(DefaultPreferencesEditor));
this.defaultPreferencesEditor.create(new Builder(this.defaultPreferencesEditorContainer));
this.defaultPreferencesEditor.setVisible(true);
(<CodeEditor>this.defaultPreferencesEditor.getControl()).onDidFocusEditor(() => this.lastFocusedEditor = this.defaultPreferencesEditor);
this.editablePreferencesEditorContainer = DOM.append(parentElement, DOM.$('.editable-preferences-editor-container'));
this.editablePreferencesEditorContainer.style.position = 'absolute';
this.editablePreferencesEditor = this._register(this.instantiationService.createInstance(EditableSettingsEditor));
this.editablePreferencesEditor.create(new Builder(this.editablePreferencesEditorContainer));
this.editablePreferencesEditor.setVisible(true);
(<CodeEditor>this.editablePreferencesEditor.getControl()).onDidFocusEditor(() => this.lastFocusedEditor = this.editablePreferencesEditor);
this.lastFocusedEditor = this.editablePreferencesEditor;
this._register(attachStylerCallback(this.themeService, { scrollbarShadow }, colors => {
const shadow = colors.scrollbarShadow ? colors.scrollbarShadow.toString() : null;
......@@ -441,6 +457,9 @@ class SideBySidePreferencesWidget extends Widget {
this.editablePreferencesEditorContainer.style.boxShadow = null;
}
}));
const focusTracker = this._register(DOM.trackFocus(parentElement));
this._register(focusTracker.addFocusListener(() => this._onFocus.fire()));
}
public setInput(defaultPreferencesEditorInput: DefaultPreferencesEditorInput, editablePreferencesEditorInput: EditorInput, options?: EditorOptions): TPromise<{ defaultPreferencesRenderer: IPreferencesRenderer<ISetting>, editablePreferencesRenderer: IPreferencesRenderer<ISetting> }> {
......@@ -456,8 +475,8 @@ class SideBySidePreferencesWidget extends Widget {
}
public focus(): void {
if (this.editablePreferencesEditor) {
this.editablePreferencesEditor.focus();
if (this.lastFocusedEditor) {
this.lastFocusedEditor.focus();
}
}
......
......@@ -384,12 +384,15 @@ export class SearchWidget extends Widget {
private searchContainer: HTMLElement;
private inputBox: InputBox;
private _onDidChange = this._register(new Emitter<string>());
private _onDidChange: Emitter<string> = this._register(new Emitter<string>());
public readonly onDidChange: Event<string> = this._onDidChange.event;
private _onNavigate = this._register(new Emitter<boolean>());
private _onNavigate: Emitter<boolean> = this._register(new Emitter<boolean>());
public readonly onNavigate: Event<boolean> = this._onNavigate.event;
private _onFocus: Emitter<void> = this._register(new Emitter<void>());
public readonly onFocus: Event<void> = this._onFocus.event;
constructor(parent: HTMLElement, protected options: SearchOptions,
@IContextViewService private contextViewService: IContextViewService,
@IContextMenuService private contextMenuService: IContextMenuService,
......@@ -418,8 +421,10 @@ export class SearchWidget extends Widget {
}));
this.inputBox.inputElement.setAttribute('aria-live', 'assertive');
const focusTracker = this._register(DOM.trackFocus(this.inputBox.inputElement));
this._register(focusTracker.addFocusListener(() => this._onFocus.fire()));
if (this.options.focusKey) {
const focusTracker = this._register(DOM.trackFocus(this.inputBox.inputElement));
this._register(focusTracker.addFocusListener(() => this.options.focusKey.set(true)));
this._register(focusTracker.addBlurListener(() => this.options.focusKey.set(false)));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册