Skip to content

Commit b0e32cc

Browse files
committed
1 parent f3654c5 commit b0e32cc

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

src/vs/workbench/parts/preferences/browser/settingsEditor2.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c
2323
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
2424
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
2525
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
26+
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2627
import { WorkbenchTree } from 'vs/platform/list/browser/listService';
2728
import { ILogService } from 'vs/platform/log/common/log';
2829
import { INotificationService } from 'vs/platform/notification/common/notification';
@@ -41,11 +42,11 @@ import { ISettingLinkClickEvent, resolveExtensionsSettings, resolveSettingsTree,
4142
import { ISettingsEditorViewState, MODIFIED_SETTING_TAG, ONLINE_SERVICES_SETTING_TAG, parseQuery, SearchResultIdx, SearchResultModel, SettingsTreeGroupElement, SettingsTreeModel, SettingsTreeSettingElement } from 'vs/workbench/parts/preferences/browser/settingsTreeModels';
4243
import { settingsTextInputBorder } from 'vs/workbench/parts/preferences/browser/settingsWidgets';
4344
import { TOCRenderer, TOCTree, TOCTreeModel } from 'vs/workbench/parts/preferences/browser/tocTree';
44-
import { SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU, CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, IPreferencesSearchService, ISearchProvider } from 'vs/workbench/parts/preferences/common/preferences';
45-
import { IPreferencesService, ISearchResult, ISettingsEditorModel, SettingsEditorOptions, ISettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences';
45+
import { CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, IPreferencesSearchService, ISearchProvider, SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU } from 'vs/workbench/parts/preferences/common/preferences';
46+
import { IPreferencesService, ISearchResult, ISettingsEditorModel, ISettingsEditorOptions, SettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences';
4647
import { SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput';
4748
import { Settings2EditorModel } from 'vs/workbench/services/preferences/common/preferencesModels';
48-
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
49+
4950
const $ = DOM.$;
5051

5152
export class SettingsEditor2 extends BaseEditor {
@@ -98,6 +99,7 @@ export class SettingsEditor2 extends BaseEditor {
9899
private searchFocusContextKey: IContextKey<boolean>;
99100

100101
private scheduledRefreshes: Map<string, DOM.IFocusTracker>;
102+
private lastFocusedSettingElement: string;
101103

102104
/** Don't spam warnings */
103105
private hasWarnedMissingSettings: boolean;
@@ -239,6 +241,17 @@ export class SettingsEditor2 extends BaseEditor {
239241
}
240242

241243
focus(): void {
244+
if (this.lastFocusedSettingElement) {
245+
const elements = this.settingsTreeRenderer.getDOMElementsForSettingKey(this.settingsTree.getHTMLElement(), this.lastFocusedSettingElement);
246+
if (elements.length) {
247+
const control = elements[0].querySelector(SettingsRenderer.CONTROL_SELECTOR);
248+
if (control) {
249+
(<HTMLElement>control).focus();
250+
return;
251+
}
252+
}
253+
}
254+
242255
this.focusSearch();
243256
}
244257

@@ -535,6 +548,7 @@ export class SettingsEditor2 extends BaseEditor {
535548
}));
536549
this._register(this.settingsTreeRenderer.onDidClickSettingLink(settingName => this.onDidClickSetting(settingName)));
537550
this._register(this.settingsTreeRenderer.onDidFocusSetting(element => {
551+
this.lastFocusedSettingElement = element.setting.key;
538552
this.settingsTree.reveal(element);
539553
}));
540554

0 commit comments

Comments
 (0)