From 44567a1304ea91ce041fde76e07937bb47fd77ba Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 28 Nov 2023 05:52:34 +0100 Subject: [PATCH] editors - reuse editor config to prevent a second lookup (#199262) --- .../workbench/browser/parts/editor/textDiffEditor.ts | 4 ++-- src/vs/workbench/browser/parts/editor/textEditor.ts | 10 ++++++---- src/vs/workbench/contrib/output/browser/logViewer.ts | 5 +++-- src/vs/workbench/contrib/output/browser/outputView.ts | 5 +++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index 9b3a2f90ba0..72a2b34fd3f 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -267,9 +267,9 @@ export class TextDiffEditor extends AbstractTextEditor imp return editorConfiguration; } - protected override getConfigurationOverrides(): IDiffEditorOptions { + protected override getConfigurationOverrides(configuration: IEditorConfiguration): IDiffEditorOptions { return { - ...super.getConfigurationOverrides(), + ...super.getConfigurationOverrides(configuration), ...this.getReadonlyConfiguration(this.input?.isReadonly()), originalEditable: this.input instanceof DiffEditorInput && !this.input.original.isReadonly(), lineDecorationsWidth: '2ch' diff --git a/src/vs/workbench/browser/parts/editor/textEditor.ts b/src/vs/workbench/browser/parts/editor/textEditor.ts index 1add196db1e..0fc1efdc5de 100644 --- a/src/vs/workbench/browser/parts/editor/textEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textEditor.ts @@ -38,6 +38,9 @@ export interface IEditorConfiguration { diffEditor?: boolean; }; }; + problems?: { + visibility?: boolean; + }; } /** @@ -116,7 +119,7 @@ export abstract class AbstractTextEditor extends Abs // Specific editor options always overwrite user configuration const editorConfiguration: ICodeEditorOptions = isObject(configuration.editor) ? deepClone(configuration.editor) : Object.create(null); - Object.assign(editorConfiguration, this.getConfigurationOverrides()); + Object.assign(editorConfiguration, this.getConfigurationOverrides(configuration)); // ARIA label editorConfiguration.ariaLabel = this.computeAriaLabel(); @@ -155,14 +158,13 @@ export abstract class AbstractTextEditor extends Abs }; } - protected getConfigurationOverrides(): ICodeEditorOptions { - const config = this.textResourceConfigurationService.getValue(this.getActiveResource(), 'problems.visibility'); + protected getConfigurationOverrides(configuration: IEditorConfiguration): ICodeEditorOptions { return { overviewRulerLanes: 3, lineNumbersMinChars: 3, fixedOverflowWidgets: true, ...this.getReadonlyConfiguration(this.input?.isReadonly()), - renderValidationDecorations: config ? 'on' : 'off' + renderValidationDecorations: configuration.problems?.visibility !== false ? 'on' : 'off' }; } diff --git a/src/vs/workbench/contrib/output/browser/logViewer.ts b/src/vs/workbench/contrib/output/browser/logViewer.ts index 417ea949d61..8446103f278 100644 --- a/src/vs/workbench/contrib/output/browser/logViewer.ts +++ b/src/vs/workbench/contrib/output/browser/logViewer.ts @@ -14,6 +14,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IFileService } from 'vs/platform/files/common/files'; +import { IEditorConfiguration } from 'vs/workbench/browser/parts/editor/textEditor'; export class LogViewer extends AbstractTextResourceEditor { @@ -32,8 +33,8 @@ export class LogViewer extends AbstractTextResourceEditor { super(LogViewer.LOG_VIEWER_EDITOR_ID, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, editorService, fileService); } - protected override getConfigurationOverrides(): IEditorOptions { - const options = super.getConfigurationOverrides(); + protected override getConfigurationOverrides(configuration: IEditorConfiguration): IEditorOptions { + const options = super.getConfigurationOverrides(configuration); options.wordWrap = 'off'; // all log viewers do not wrap options.folding = false; options.scrollBeyondLastLine = false; diff --git a/src/vs/workbench/contrib/output/browser/outputView.ts b/src/vs/workbench/contrib/output/browser/outputView.ts index a8af8c5da05..aad161b5818 100644 --- a/src/vs/workbench/contrib/output/browser/outputView.ts +++ b/src/vs/workbench/contrib/output/browser/outputView.ts @@ -34,6 +34,7 @@ import { CancelablePromise, createCancelablePromise } from 'vs/base/common/async import { IFileService } from 'vs/platform/files/common/files'; import { ResourceContextKey } from 'vs/workbench/common/contextkeys'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; +import { IEditorConfiguration } from 'vs/workbench/browser/parts/editor/textEditor'; export class OutputViewPane extends ViewPane { @@ -177,8 +178,8 @@ class OutputEditor extends AbstractTextResourceEditor { return nls.localize('output', "Output"); } - protected override getConfigurationOverrides(): ICodeEditorOptions { - const options = super.getConfigurationOverrides(); + protected override getConfigurationOverrides(configuration: IEditorConfiguration): ICodeEditorOptions { + const options = super.getConfigurationOverrides(configuration); options.wordWrap = 'on'; // all output editors wrap options.lineNumbers = 'off'; // all output editors hide line numbers options.glyphMargin = false;