mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Fixes #206558
This commit is contained in:
parent
12b7fd98c3
commit
17e86debf7
|
@ -3,10 +3,11 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IObservable, ISettableObservable, derived, observableValue } from 'vs/base/common/observable';
|
||||
import { IObservable, ISettableObservable, derived, observableFromEvent, observableValue } from 'vs/base/common/observable';
|
||||
import { Constants } from 'vs/base/common/uint';
|
||||
import { diffEditorDefaultOptions } from 'vs/editor/common/config/diffEditor';
|
||||
import { IDiffEditorBaseOptions, IDiffEditorOptions, IEditorOptions, ValidDiffEditorBaseOptions, clampedFloat, clampedInt, boolean as validateBooleanOption, stringSet as validateStringSetOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||
|
||||
export class DiffEditorOptions {
|
||||
private readonly _options: ISettableObservable<IEditorOptions & Required<IDiffEditorBaseOptions>, { changedOptions: IDiffEditorOptions }>;
|
||||
|
@ -15,8 +16,11 @@ export class DiffEditorOptions {
|
|||
|
||||
private readonly _diffEditorWidth = observableValue<number>(this, 0);
|
||||
|
||||
private readonly _screenReaderMode = observableFromEvent(this._accessibilityService.onDidChangeScreenReaderOptimized, () => this._accessibilityService.isScreenReaderOptimized());
|
||||
|
||||
constructor(
|
||||
options: Readonly<IDiffEditorOptions>,
|
||||
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
|
||||
) {
|
||||
const optionsCopy = { ...options, ...validateDiffEditorOptions(options, diffEditorDefaultOptions) };
|
||||
this._options = observableValue(this, optionsCopy);
|
||||
|
@ -28,7 +32,7 @@ export class DiffEditorOptions {
|
|||
|
||||
public readonly renderOverviewRuler = derived(this, reader => this._options.read(reader).renderOverviewRuler);
|
||||
public readonly renderSideBySide = derived(this, reader => this._options.read(reader).renderSideBySide
|
||||
&& !(this._options.read(reader).useInlineViewWhenSpaceIsLimited && this.couldShowInlineViewBecauseOfSize.read(reader))
|
||||
&& !(this._options.read(reader).useInlineViewWhenSpaceIsLimited && this.couldShowInlineViewBecauseOfSize.read(reader) && !this._screenReaderMode.read(reader))
|
||||
);
|
||||
public readonly readOnly = derived(this, reader => this._options.read(reader).readOnly);
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ export class DiffEditorWidget extends DelegatingEditor implements IDiffEditor {
|
|||
this._rootSizeObserver = this._register(new ObservableElementSizeObserver(this.elements.root, options.dimension));
|
||||
this._rootSizeObserver.setAutomaticLayout(options.automaticLayout ?? false);
|
||||
|
||||
this._options = new DiffEditorOptions(options);
|
||||
this._options = this._instantiationService.createInstance(DiffEditorOptions, options);
|
||||
this._register(autorun(reader => {
|
||||
this._options.setWidth(this._rootSizeObserver.width.read(reader));
|
||||
}));
|
||||
|
|
|
@ -87,7 +87,7 @@ export class DocumentDiffItemViewModel extends Disposable {
|
|||
};
|
||||
}
|
||||
|
||||
const options = new DiffEditorOptions(updateOptions(this.entry.value!.options || {}));
|
||||
const options = this._instantiationService.createInstance(DiffEditorOptions, updateOptions(this.entry.value!.options || {}));
|
||||
if (this.entry.value!.onOptionsDidChange) {
|
||||
this._register(this.entry.value!.onOptionsDidChange(() => {
|
||||
options.updateOptions(updateOptions(this.entry.value!.options || {}));
|
||||
|
|
Loading…
Reference in a new issue