add workbench.list.automaticKeyboardNavigation setting

fixes #68233
This commit is contained in:
Joao Moreno
2019-02-20 10:42:07 +01:00
parent 0767b1b8d1
commit b40585bffc

View File

@@ -113,6 +113,7 @@ export const multiSelectModifierSettingKey = 'workbench.list.multiSelectModifier
export const openModeSettingKey = 'workbench.list.openMode';
export const horizontalScrollingKey = 'workbench.tree.horizontalScrolling';
export const keyboardNavigationSettingKey = 'workbench.list.keyboardNavigation';
export const automaticKeyboardNavigationSettingKey = 'workbench.list.automaticKeyboardNavigation';
const treeIndentKey = 'workbench.tree.indent';
function useAltAsMultipleSelectionModifier(configurationService: IConfigurationService): boolean {
@@ -785,7 +786,17 @@ export class WorkbenchObjectTree<T extends NonNullable<any>, TFilterData = void>
didBindWorkbenchListAutomaticKeyboardNavigation = true;
}
const automaticKeyboardNavigation = contextKeyService.getContextKeyValue<boolean>(WorkbenchListAutomaticKeyboardNavigationKey);
const getAutomaticKeyboardNavigation = () => {
// give priority to the context key value to disable this completely
let automaticKeyboardNavigation = contextKeyService.getContextKeyValue<boolean>(WorkbenchListAutomaticKeyboardNavigationKey);
if (automaticKeyboardNavigation) {
automaticKeyboardNavigation = configurationService.getValue<boolean>(automaticKeyboardNavigationSettingKey);
}
return automaticKeyboardNavigation;
};
const keyboardNavigation = configurationService.getValue<string>(keyboardNavigationSettingKey);
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : configurationService.getValue<boolean>(horizontalScrollingKey);
const openOnSingleClick = useSingleClickToOpen(configurationService);
@@ -797,7 +808,7 @@ export class WorkbenchObjectTree<T extends NonNullable<any>, TFilterData = void>
...computeStyles(themeService.getTheme(), defaultListStyles),
...workbenchListOptions,
indent: configurationService.getValue(treeIndentKey),
automaticKeyboardNavigation,
automaticKeyboardNavigation: getAutomaticKeyboardNavigation(),
simpleKeyboardNavigation: keyboardNavigation === 'simple',
filterOnType: keyboardNavigation === 'filter',
horizontalScrolling,
@@ -857,13 +868,13 @@ export class WorkbenchObjectTree<T extends NonNullable<any>, TFilterData = void>
filterOnType: keyboardNavigation === 'filter'
});
}
if (e.affectsConfiguration(automaticKeyboardNavigationSettingKey)) {
this.updateOptions({ automaticKeyboardNavigation: getAutomaticKeyboardNavigation() });
}
}),
this.contextKeyService.onDidChangeContext(e => {
if (e.affectsSome(interestingContextKeys)) {
const automaticKeyboardNavigation = this.contextKeyService.getContextKeyValue<boolean>(WorkbenchListAutomaticKeyboardNavigationKey);
this.updateOptions({
automaticKeyboardNavigation
});
this.updateOptions({ automaticKeyboardNavigation: getAutomaticKeyboardNavigation() });
}
})
);
@@ -908,7 +919,17 @@ export class WorkbenchDataTree<TInput, T, TFilterData = void> extends DataTree<T
didBindWorkbenchListAutomaticKeyboardNavigation = true;
}
const automaticKeyboardNavigation = contextKeyService.getContextKeyValue<boolean>(WorkbenchListAutomaticKeyboardNavigationKey);
const getAutomaticKeyboardNavigation = () => {
// give priority to the context key value to disable this completely
let automaticKeyboardNavigation = contextKeyService.getContextKeyValue<boolean>(WorkbenchListAutomaticKeyboardNavigationKey);
if (automaticKeyboardNavigation) {
automaticKeyboardNavigation = configurationService.getValue<boolean>(automaticKeyboardNavigationSettingKey);
}
return automaticKeyboardNavigation;
};
const keyboardNavigation = configurationService.getValue<string>(keyboardNavigationSettingKey);
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : configurationService.getValue<boolean>(horizontalScrollingKey);
const openOnSingleClick = useSingleClickToOpen(configurationService);
@@ -920,7 +941,7 @@ export class WorkbenchDataTree<TInput, T, TFilterData = void> extends DataTree<T
...computeStyles(themeService.getTheme(), defaultListStyles),
...workbenchListOptions,
indent: configurationService.getValue(treeIndentKey),
automaticKeyboardNavigation,
automaticKeyboardNavigation: getAutomaticKeyboardNavigation(),
simpleKeyboardNavigation: keyboardNavigation === 'simple',
filterOnType: keyboardNavigation === 'filter',
horizontalScrolling,
@@ -980,13 +1001,13 @@ export class WorkbenchDataTree<TInput, T, TFilterData = void> extends DataTree<T
filterOnType: keyboardNavigation === 'filter'
});
}
if (e.affectsConfiguration(automaticKeyboardNavigationSettingKey)) {
this.updateOptions({ automaticKeyboardNavigation: getAutomaticKeyboardNavigation() });
}
}),
this.contextKeyService.onDidChangeContext(e => {
if (e.affectsSome(interestingContextKeys)) {
const automaticKeyboardNavigation = this.contextKeyService.getContextKeyValue<boolean>(WorkbenchListAutomaticKeyboardNavigationKey);
this.updateOptions({
automaticKeyboardNavigation
});
this.updateOptions({ automaticKeyboardNavigation: getAutomaticKeyboardNavigation() });
}
})
);
@@ -1026,7 +1047,17 @@ export class WorkbenchAsyncDataTree<TInput, T, TFilterData = void> extends Async
didBindWorkbenchListAutomaticKeyboardNavigation = true;
}
const automaticKeyboardNavigation = contextKeyService.getContextKeyValue<boolean>(WorkbenchListAutomaticKeyboardNavigationKey);
const getAutomaticKeyboardNavigation = () => {
// give priority to the context key value to disable this completely
let automaticKeyboardNavigation = contextKeyService.getContextKeyValue<boolean>(WorkbenchListAutomaticKeyboardNavigationKey);
if (automaticKeyboardNavigation) {
automaticKeyboardNavigation = configurationService.getValue<boolean>(automaticKeyboardNavigationSettingKey);
}
return automaticKeyboardNavigation;
};
const keyboardNavigation = configurationService.getValue<string>(keyboardNavigationSettingKey);
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : configurationService.getValue<boolean>(horizontalScrollingKey);
const openOnSingleClick = useSingleClickToOpen(configurationService);
@@ -1038,7 +1069,7 @@ export class WorkbenchAsyncDataTree<TInput, T, TFilterData = void> extends Async
...computeStyles(themeService.getTheme(), defaultListStyles),
...workbenchListOptions,
indent: configurationService.getValue<number>(treeIndentKey),
automaticKeyboardNavigation,
automaticKeyboardNavigation: getAutomaticKeyboardNavigation(),
simpleKeyboardNavigation: keyboardNavigation === 'simple',
filterOnType: keyboardNavigation === 'filter',
horizontalScrolling,
@@ -1098,13 +1129,13 @@ export class WorkbenchAsyncDataTree<TInput, T, TFilterData = void> extends Async
filterOnType: keyboardNavigation === 'filter'
});
}
if (e.affectsConfiguration(automaticKeyboardNavigationSettingKey)) {
this.updateOptions({ automaticKeyboardNavigation: getAutomaticKeyboardNavigation() });
}
}),
this.contextKeyService.onDidChangeContext(e => {
if (e.affectsSome(interestingContextKeys)) {
const automaticKeyboardNavigation = this.contextKeyService.getContextKeyValue<boolean>(WorkbenchListAutomaticKeyboardNavigationKey);
this.updateOptions({
automaticKeyboardNavigation
});
this.updateOptions({ automaticKeyboardNavigation: getAutomaticKeyboardNavigation() });
}
})
);
@@ -1171,5 +1202,10 @@ configurationRegistry.registerConfiguration({
'default': 'highlight',
'description': localize('keyboardNavigationSettingKey', "Controls the keyboard navigation style for lists and trees in the workbench. Can be simple, highlight and filter.")
},
[automaticKeyboardNavigationSettingKey]: {
'type': 'boolean',
'default': true,
'description': localize('automatic keyboard navigation setting', "Controls whether keyboard navigation in lists and trees is automatically triggered simply by typing. If set to `false`, keyboard navigation is only triggered when executing the `list.toggleKeyboardNavigation` command, for which you can assign a keyboard shortcut.")
}
}
});