mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
💄 editor configuration handling (#171029)
This commit is contained in:
parent
6d25477523
commit
c82c88f53a
|
@ -233,8 +233,8 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
|
|||
}
|
||||
}
|
||||
|
||||
protected override shouldComputeConfiguration(e: ITextResourceConfigurationChangeEvent, resource: URI): boolean {
|
||||
if (super.shouldComputeConfiguration(e, resource)) {
|
||||
protected override shouldHandleConfigurationChangeEvent(e: ITextResourceConfigurationChangeEvent, resource: URI): boolean {
|
||||
if (super.shouldHandleConfigurationChangeEvent(e, resource)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,16 +64,8 @@ export abstract class AbstractTextEditor<T extends IEditorViewState> extends Abs
|
|||
) {
|
||||
super(id, AbstractTextEditor.VIEW_STATE_PREFERENCE_KEY, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorService, editorGroupService);
|
||||
|
||||
this._register(this.textResourceConfigurationService.onDidChangeConfiguration(e => {
|
||||
const resource = this.getActiveResource();
|
||||
if (!this.shouldComputeConfiguration(e, resource)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const value = resource ? this.textResourceConfigurationService.getValue<IEditorConfiguration>(resource) : undefined;
|
||||
|
||||
return this.handleConfigurationChangeEvent(value);
|
||||
}));
|
||||
// Listen to configuration changes
|
||||
this._register(this.textResourceConfigurationService.onDidChangeConfiguration(e => this.handleConfigurationChangeEvent(e)));
|
||||
|
||||
// ARIA: if a group is added or removed, update the editor's ARIA
|
||||
// label so that it appears in the label for when there are > 1 groups
|
||||
|
@ -90,14 +82,23 @@ export abstract class AbstractTextEditor<T extends IEditorViewState> extends Abs
|
|||
this._register(this.fileService.onDidChangeFileSystemProviderRegistrations(e => this.onDidChangeFileSystemProvider(e.scheme)));
|
||||
}
|
||||
|
||||
private handleConfigurationChangeEvent(configuration?: IEditorConfiguration): void {
|
||||
private handleConfigurationChangeEvent(e: ITextResourceConfigurationChangeEvent): void {
|
||||
const resource = this.getActiveResource();
|
||||
if (!this.shouldHandleConfigurationChangeEvent(e, resource)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isVisible()) {
|
||||
this.updateEditorConfiguration(configuration);
|
||||
this.updateEditorConfiguration(resource);
|
||||
} else {
|
||||
this.hasPendingConfigurationChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected shouldHandleConfigurationChangeEvent(e: ITextResourceConfigurationChangeEvent, resource: URI | undefined): boolean {
|
||||
return e.affectsConfiguration(resource, 'editor');
|
||||
}
|
||||
|
||||
private consumePendingConfigurationChangeEvent(): void {
|
||||
if (this.hasPendingConfigurationChange) {
|
||||
this.updateEditorConfiguration();
|
||||
|
@ -105,10 +106,6 @@ export abstract class AbstractTextEditor<T extends IEditorViewState> extends Abs
|
|||
}
|
||||
}
|
||||
|
||||
protected shouldComputeConfiguration(e: ITextResourceConfigurationChangeEvent, resource: URI | undefined): boolean {
|
||||
return e.affectsConfiguration(resource, 'editor');
|
||||
}
|
||||
|
||||
protected computeConfiguration(configuration: IEditorConfiguration): ICodeEditorOptions {
|
||||
|
||||
// Specific editor options always overwrite user configuration
|
||||
|
@ -257,13 +254,11 @@ export abstract class AbstractTextEditor<T extends IEditorViewState> extends Abs
|
|||
return input.resource;
|
||||
}
|
||||
|
||||
private updateEditorConfiguration(configuration?: IEditorConfiguration): void {
|
||||
if (!configuration) {
|
||||
const resource = this.getActiveResource();
|
||||
private updateEditorConfiguration(resource = this.getActiveResource()): void {
|
||||
let configuration: IEditorConfiguration | undefined = undefined;
|
||||
if (resource) {
|
||||
configuration = this.textResourceConfigurationService.getValue<IEditorConfiguration>(resource);
|
||||
}
|
||||
}
|
||||
|
||||
if (!configuration) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue