提交 08291897 编写于 作者: R Rob Lourens

#52815 - Settings editor - 'enter' edits setting

上级 065a1000
......@@ -155,6 +155,14 @@ export class SettingsEditor2 extends BaseEditor {
this.searchWidget.focus();
}
editSelectedSetting(): void {
const focus = this.settingsTree.getFocus();
if (focus instanceof SettingsTreeSettingElement) {
const itemId = focus.id.replace(/\./g, '_');
this.focusEditControlForRow(itemId);
}
}
clearSearchResults(): void {
this.searchWidget.clear();
}
......@@ -585,14 +593,7 @@ export class SettingsEditor2 extends BaseEditor {
return this.settingsTree.refresh()
.then(() => {
if (focusedRowId) {
const rowSelector = `.setting-item#${focusedRowId}`;
const inputElementToFocus: HTMLElement = this.settingsTreeContainer.querySelector(`${rowSelector} input, ${rowSelector} select, ${rowSelector} a, ${rowSelector} .monaco-custom-checkbox`);
if (inputElementToFocus) {
inputElementToFocus.focus();
if (typeof selection === 'number') {
(<HTMLInputElement>inputElementToFocus).setSelectionRange(selection, selection);
}
}
this.focusEditControlForRow(focusedRowId, selection);
}
})
.then(() => {
......@@ -600,6 +601,17 @@ export class SettingsEditor2 extends BaseEditor {
});
}
private focusEditControlForRow(id: string, selection?: number): void {
const rowSelector = `.setting-item#${id}`;
const inputElementToFocus: HTMLElement = this.settingsTreeContainer.querySelector(`${rowSelector} input, ${rowSelector} select, ${rowSelector} a, ${rowSelector} .monaco-custom-checkbox`);
if (inputElementToFocus) {
inputElementToFocus.focus();
if (typeof selection === 'number') {
(<HTMLInputElement>inputElementToFocus).setSelectionRange(selection, selection);
}
}
}
private onSearchInputChanged(): void {
const query = this.searchWidget.getValue().trim();
this.delayedFilterLogging.cancel();
......
......@@ -465,3 +465,21 @@ const editFocusedSettingCommand = new EditFocusedSettingCommand({
kbOpts: { primary: KeyMod.CtrlCmd | KeyCode.US_DOT }
});
KeybindingsRegistry.registerCommandAndKeybindingRule(editFocusedSettingCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib()));
class EditFocusedSettingCommand2 extends SettingsCommand {
public runCommand(accessor: ServicesAccessor, args: any): void {
const preferencesEditor = this.getPreferencesEditor(accessor);
if (preferencesEditor instanceof SettingsEditor2) {
preferencesEditor.editSelectedSetting();
}
}
}
const editFocusedSettingCommand2 = new EditFocusedSettingCommand2({
id: SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING,
precondition: CONTEXT_SETTINGS_EDITOR,
kbOpts: { primary: KeyCode.Enter }
});
KeybindingsRegistry.registerCommandAndKeybindingRule(editFocusedSettingCommand2.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.workbenchContrib()));
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册