未验证 提交 ce905717 编写于 作者: L Logan Ramos

First part of #125422

上级 e5b6f390
......@@ -363,7 +363,7 @@ export class CodeApplication extends Disposable {
// Explicitly opt out of the patch here before creating any windows.
// See: https://github.com/microsoft/vscode/issues/35361#issuecomment-399794085
try {
if (isMacintosh && this.configurationService.getValue<boolean>('window.nativeTabs') === true && !systemPreferences.getUserDefault('NSUseImprovedLayoutPass', 'boolean')) {
if (isMacintosh && this.configurationService.getValue('window.nativeTabs') === true && !systemPreferences.getUserDefault('NSUseImprovedLayoutPass', 'boolean')) {
systemPreferences.setUserDefault('NSUseImprovedLayoutPass', 'boolean', true as any);
}
} catch (error) {
......@@ -976,7 +976,8 @@ export class CodeApplication extends Disposable {
const argvString = argvContent.value.toString();
const argvJSON = JSON.parse(stripComments(argvString));
if (argvJSON['enable-crash-reporter'] === undefined) {
const enableCrashReporter = this.configurationService.getValue<boolean>('telemetry.enableCrashReporter') ?? true;
const enableCrashReporterSetting = this.configurationService.getValue('telemetry.enableCrashReporter');
const enableCrashReporter = typeof enableCrashReporterSetting === 'boolean' ? enableCrashReporterSetting : true;
const additionalArgvContent = [
'',
' // Allows to disable crash reporting.',
......
......@@ -249,15 +249,15 @@ export class ModelServiceImpl extends Disposable implements IModelService {
if (resource) {
return this._resourcePropertiesService.getEOL(resource, language);
}
const eol = this._configurationService.getValue<string>('files.eol', { overrideIdentifier: language });
if (eol && eol !== 'auto') {
const eol = this._configurationService.getValue('files.eol', { overrideIdentifier: language });
if (eol && typeof eol === 'string' && eol !== 'auto') {
return eol;
}
return platform.OS === platform.OperatingSystem.Linux || platform.OS === platform.OperatingSystem.Macintosh ? '\n' : '\r\n';
}
private _shouldRestoreUndoStack(): boolean {
const result = this._configurationService.getValue<boolean>('files.restoreUndoStack');
const result = this._configurationService.getValue('files.restoreUndoStack');
if (typeof result === 'boolean') {
return result;
}
......
......@@ -77,8 +77,8 @@ export class ColorDetector extends Disposable implements IEditorContribution {
}
const languageId = model.getLanguageIdentifier();
// handle deprecated settings. [languageId].colorDecorators.enable
const deprecatedConfig = this._configurationService.getValue<{}>(languageId.language);
if (deprecatedConfig) {
const deprecatedConfig = this._configurationService.getValue(languageId.language);
if (deprecatedConfig && typeof deprecatedConfig === 'object') {
const colorDecorators = (deprecatedConfig as any)['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable');
if (colorDecorators && colorDecorators['enable'] !== undefined && !colorDecorators['enable']) {
return colorDecorators['enable'];
......
......@@ -77,8 +77,8 @@ export class MarkdownHoverParticipant implements IEditorHoverParticipant<Markdow
}
const lineLength = this._editor.getModel().getLineLength(lineNumber);
const maxTokenizationLineLength = this._configurationService.getValue<number>('editor.maxTokenizationLineLength');
if (lineLength >= maxTokenizationLineLength) {
const maxTokenizationLineLength = this._configurationService.getValue('editor.maxTokenizationLineLength');
if (typeof maxTokenizationLineLength === 'number' && lineLength >= maxTokenizationLineLength) {
result.push(new MarkdownHover(this, new Range(lineNumber, 1, lineNumber, lineLength + 1), [{
value: nls.localize('too many characters', "Tokenization is skipped for long lines for performance reasons. This can be configured via `editor.maxTokenizationLineLength`.")
}]));
......
......@@ -99,15 +99,15 @@ export const enum State {
function shouldPreventQuickSuggest(contextKeyService: IContextKeyService, configurationService: IConfigurationService): boolean {
return (
Boolean(contextKeyService.getContextKeyValue<boolean>('inlineSuggestionVisible'))
&& !Boolean(configurationService.getValue<boolean>('editor.inlineSuggest.allowQuickSuggestions'))
Boolean(contextKeyService.getContextKeyValue('inlineSuggestionVisible'))
&& !Boolean(configurationService.getValue('editor.inlineSuggest.allowQuickSuggestions'))
);
}
function shouldPreventSuggestOnTriggerCharacters(contextKeyService: IContextKeyService, configurationService: IConfigurationService): boolean {
return (
Boolean(contextKeyService.getContextKeyValue<boolean>('inlineSuggestionVisible'))
&& !Boolean(configurationService.getValue<boolean>('editor.inlineSuggest.allowSuggestOnTriggerCharacters'))
Boolean(contextKeyService.getContextKeyValue('inlineSuggestionVisible'))
&& !Boolean(configurationService.getValue('editor.inlineSuggest.allowSuggestOnTriggerCharacters'))
);
}
......
......@@ -563,8 +563,8 @@ export class SimpleResourcePropertiesService implements ITextResourcePropertiesS
}
getEOL(resource: URI, language?: string): string {
const eol = this.configurationService.getValue<string>('files.eol', { overrideIdentifier: language, resource });
if (eol && eol !== 'auto') {
const eol = this.configurationService.getValue('files.eol', { overrideIdentifier: language, resource });
if (eol && typeof eol === 'string' && eol !== 'auto') {
return eol;
}
return (isLinux || isMacintosh) ? '\n' : '\r\n';
......
......@@ -18,8 +18,8 @@ export class TestTextResourcePropertiesService implements ITextResourcePropertie
}
getEOL(resource: URI, language?: string): string {
const eol = this.configurationService.getValue<string>('files.eol', { overrideIdentifier: language, resource });
if (eol && eol !== 'auto') {
const eol = this.configurationService.getValue('files.eol', { overrideIdentifier: language, resource });
if (eol && typeof eol === 'string' && eol !== 'auto') {
return eol;
}
return (platform.isLinux || platform.isMacintosh) ? '\n' : '\r\n';
......
......@@ -183,7 +183,7 @@ function toWorkbenchListOptions<T>(options: IListOptions<T>, configurationServic
}
};
result.smoothScrolling = Boolean(configurationService.getValue<boolean>(listSmoothScrolling));
result.smoothScrolling = Boolean(configurationService.getValue(listSmoothScrolling));
return [result, disposables];
}
......@@ -222,7 +222,7 @@ export class WorkbenchList<T> extends List<T> {
@IConfigurationService configurationService: IConfigurationService,
@IKeybindingService keybindingService: IKeybindingService
) {
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue<boolean>(horizontalScrollingKey));
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
const [workbenchListOptions, workbenchListOptionsDisposable] = toWorkbenchListOptions(options, configurationService, keybindingService);
super(user, container, delegate, renderers,
......@@ -283,11 +283,11 @@ export class WorkbenchList<T> extends List<T> {
let options: IListOptionsUpdate = {};
if (e.affectsConfiguration(horizontalScrollingKey) && this.horizontalScrolling === undefined) {
const horizontalScrolling = Boolean(configurationService.getValue<boolean>(horizontalScrollingKey));
const horizontalScrolling = Boolean(configurationService.getValue(horizontalScrollingKey));
options = { ...options, horizontalScrolling };
}
if (e.affectsConfiguration(listSmoothScrolling)) {
const smoothScrolling = Boolean(configurationService.getValue<boolean>(listSmoothScrolling));
const smoothScrolling = Boolean(configurationService.getValue(listSmoothScrolling));
options = { ...options, smoothScrolling };
}
if (Object.keys(options).length > 0) {
......@@ -354,7 +354,7 @@ export class WorkbenchPagedList<T> extends PagedList<T> {
@IConfigurationService configurationService: IConfigurationService,
@IKeybindingService keybindingService: IKeybindingService
) {
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue<boolean>(horizontalScrollingKey));
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
const [workbenchListOptions, workbenchListOptionsDisposable] = toWorkbenchListOptions(options, configurationService, keybindingService);
super(user, container, delegate, renderers,
{
......@@ -400,11 +400,11 @@ export class WorkbenchPagedList<T> extends PagedList<T> {
let options: IListOptionsUpdate = {};
if (e.affectsConfiguration(horizontalScrollingKey) && this.horizontalScrolling === undefined) {
const horizontalScrolling = Boolean(configurationService.getValue<boolean>(horizontalScrollingKey));
const horizontalScrolling = Boolean(configurationService.getValue(horizontalScrollingKey));
options = { ...options, horizontalScrolling };
}
if (e.affectsConfiguration(listSmoothScrolling)) {
const smoothScrolling = Boolean(configurationService.getValue<boolean>(listSmoothScrolling));
const smoothScrolling = Boolean(configurationService.getValue(listSmoothScrolling));
options = { ...options, smoothScrolling };
}
if (Object.keys(options).length > 0) {
......@@ -480,7 +480,7 @@ export class WorkbenchTable<TRow> extends Table<TRow> {
@IConfigurationService configurationService: IConfigurationService,
@IKeybindingService keybindingService: IKeybindingService
) {
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue<boolean>(horizontalScrollingKey));
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
const [workbenchListOptions, workbenchListOptionsDisposable] = toWorkbenchListOptions(options, configurationService, keybindingService);
super(user, container, delegate, columns, renderers,
......@@ -542,11 +542,11 @@ export class WorkbenchTable<TRow> extends Table<TRow> {
let options: IListOptionsUpdate = {};
if (e.affectsConfiguration(horizontalScrollingKey) && this.horizontalScrolling === undefined) {
const horizontalScrolling = Boolean(configurationService.getValue<boolean>(horizontalScrollingKey));
const horizontalScrolling = Boolean(configurationService.getValue(horizontalScrollingKey));
options = { ...options, horizontalScrolling };
}
if (e.affectsConfiguration(listSmoothScrolling)) {
const smoothScrolling = Boolean(configurationService.getValue<boolean>(listSmoothScrolling));
const smoothScrolling = Boolean(configurationService.getValue(listSmoothScrolling));
options = { ...options, smoothScrolling };
}
if (Object.keys(options).length > 0) {
......@@ -1030,10 +1030,10 @@ function workbenchTreeDataPreamble<T, TFilterData, TOptions extends IAbstractTre
const getAutomaticKeyboardNavigation = () => {
// give priority to the context key value to disable this completely
let automaticKeyboardNavigation = Boolean(contextKeyService.getContextKeyValue<boolean>(WorkbenchListAutomaticKeyboardNavigationKey));
let automaticKeyboardNavigation = Boolean(contextKeyService.getContextKeyValue(WorkbenchListAutomaticKeyboardNavigationKey));
if (automaticKeyboardNavigation) {
automaticKeyboardNavigation = Boolean(configurationService.getValue<boolean>(automaticKeyboardNavigationSettingKey));
automaticKeyboardNavigation = Boolean(configurationService.getValue(automaticKeyboardNavigationSettingKey));
}
return automaticKeyboardNavigation;
......@@ -1041,7 +1041,7 @@ function workbenchTreeDataPreamble<T, TFilterData, TOptions extends IAbstractTre
const accessibilityOn = accessibilityService.isScreenReaderOptimized();
const keyboardNavigation = options.simpleKeyboardNavigation || accessibilityOn ? 'simple' : configurationService.getValue<string>(keyboardNavigationSettingKey);
const horizontalScrolling = options.horizontalScrolling !== undefined ? options.horizontalScrolling : Boolean(configurationService.getValue<boolean>(horizontalScrollingKey));
const horizontalScrolling = options.horizontalScrolling !== undefined ? options.horizontalScrolling : Boolean(configurationService.getValue(horizontalScrollingKey));
const [workbenchListOptions, disposable] = toWorkbenchListOptions(options, configurationService, keybindingService);
const additionalScrollHeight = options.additionalScrollHeight;
......@@ -1052,9 +1052,9 @@ function workbenchTreeDataPreamble<T, TFilterData, TOptions extends IAbstractTre
// ...options, // TODO@Joao why is this not splatted here?
keyboardSupport: false,
...workbenchListOptions,
indent: configurationService.getValue<number>(treeIndentKey),
indent: typeof configurationService.getValue(treeIndentKey) === 'number' ? configurationService.getValue(treeIndentKey) : undefined,
renderIndentGuides: configurationService.getValue<RenderIndentGuides>(treeRenderIndentGuidesKey),
smoothScrolling: Boolean(configurationService.getValue<boolean>(listSmoothScrolling)),
smoothScrolling: Boolean(configurationService.getValue(listSmoothScrolling)),
automaticKeyboardNavigation: getAutomaticKeyboardNavigation(),
simpleKeyboardNavigation: keyboardNavigation === 'simple',
filterOnType: keyboardNavigation === 'filter',
......
......@@ -175,9 +175,9 @@ export class Menubar {
}
private get currentEnableMenuBarMnemonics(): boolean {
let enableMenuBarMnemonics = this.configurationService.getValue<boolean>('window.enableMenuBarMnemonics');
let enableMenuBarMnemonics = this.configurationService.getValue('window.enableMenuBarMnemonics');
if (typeof enableMenuBarMnemonics !== 'boolean') {
enableMenuBarMnemonics = true;
return true;
}
return enableMenuBarMnemonics;
......@@ -188,9 +188,9 @@ export class Menubar {
return false;
}
let enableNativeTabs = this.configurationService.getValue<boolean>('window.nativeTabs');
let enableNativeTabs = this.configurationService.getValue('window.nativeTabs');
if (typeof enableNativeTabs !== 'boolean') {
enableNativeTabs = false;
return false;
}
return enableNativeTabs;
}
......
......@@ -42,11 +42,11 @@ export class ToggleColumnSelectionAction extends Action2 {
const configurationService = accessor.get(IConfigurationService);
const codeEditorService = accessor.get(ICodeEditorService);
const oldValue = configurationService.getValue<boolean>('editor.columnSelection');
const oldValue = configurationService.getValue('editor.columnSelection');
const codeEditor = this._getCodeEditor(codeEditorService);
await configurationService.updateValue('editor.columnSelection', !oldValue);
const newValue = configurationService.getValue<boolean>('editor.columnSelection');
if (!codeEditor || codeEditor !== this._getCodeEditor(codeEditorService) || oldValue === newValue || !codeEditor.hasModel()) {
const newValue = configurationService.getValue('editor.columnSelection');
if (!codeEditor || codeEditor !== this._getCodeEditor(codeEditorService) || oldValue === newValue || !codeEditor.hasModel() || typeof oldValue !== 'boolean' || typeof newValue !== 'boolean') {
return;
}
const viewModel = codeEditor._getViewModel();
......
......@@ -36,7 +36,7 @@ export class ToggleMinimapAction extends Action2 {
override async run(accessor: ServicesAccessor): Promise<void> {
const configurationService = accessor.get(IConfigurationService);
const newValue = !configurationService.getValue<boolean>('editor.minimap.enabled');
const newValue = !configurationService.getValue('editor.minimap.enabled');
return configurationService.updateValue('editor.minimap.enabled', newValue);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册