diff --git a/build/monaco/monaco.usage.recipe b/build/monaco/monaco.usage.recipe index e3c8cdd0916..a3369eb25a7 100644 --- a/build/monaco/monaco.usage.recipe +++ b/build/monaco/monaco.usage.recipe @@ -35,6 +35,6 @@ import * as editorAPI from './vs/editor/editor.api'; a = editorAPI.editor; a = editorAPI.languages; - const o: IObservable = null!; + const o: IObservable = null!; o.TChange; })(); diff --git a/src/vs/base/common/event.ts b/src/vs/base/common/event.ts index 82921d00dac..d49f2ef276f 100644 --- a/src/vs/base/common/event.ts +++ b/src/vs/base/common/event.ts @@ -9,7 +9,7 @@ import { onUnexpectedError } from './errors.js'; import { createSingleCallFunction } from './functional.js'; import { combinedDisposable, Disposable, DisposableMap, DisposableStore, IDisposable, toDisposable } from './lifecycle.js'; import { LinkedList } from './linkedList.js'; -import { IObservable, IObserver } from './observable.js'; +import { IObservable, IObservableWithChange, IObserver } from './observable.js'; import { StopWatch } from './stopwatch.js'; import { MicrotaskDelay } from './symbols.js'; @@ -666,7 +666,7 @@ export namespace Event { private _counter = 0; private _hasChanged = false; - constructor(readonly _observable: IObservable, store: DisposableStore | undefined) { + constructor(readonly _observable: IObservable, store: DisposableStore | undefined) { const options: EmitterOptions = { onWillAddFirstListener: () => { _observable.addObserver(this); @@ -687,21 +687,21 @@ export namespace Event { } } - beginUpdate(_observable: IObservable): void { + beginUpdate(_observable: IObservable): void { // assert(_observable === this.obs); this._counter++; } - handlePossibleChange(_observable: IObservable): void { + handlePossibleChange(_observable: IObservable): void { // assert(_observable === this.obs); } - handleChange(_observable: IObservable, _change: TChange): void { + handleChange(_observable: IObservableWithChange, _change: TChange): void { // assert(_observable === this.obs); this._hasChanged = true; } - endUpdate(_observable: IObservable): void { + endUpdate(_observable: IObservable): void { // assert(_observable === this.obs); this._counter--; if (this._counter === 0) { @@ -718,7 +718,7 @@ export namespace Event { * Creates an event emitter that is fired when the observable changes. * Each listeners subscribes to the emitter. */ - export function fromObservable(obs: IObservable, store?: DisposableStore): Event { + export function fromObservable(obs: IObservable, store?: DisposableStore): Event { const observer = new EmitterObserver(obs, store); return observer.emitter.event; } @@ -726,7 +726,7 @@ export namespace Event { /** * Each listener is attached to the observable directly. */ - export function fromObservableLight(observable: IObservable): Event { + export function fromObservableLight(observable: IObservable): Event { return (listener, thisArgs, disposables) => { let count = 0; let didChange = false; diff --git a/src/vs/base/common/observableInternal/autorun.ts b/src/vs/base/common/observableInternal/autorun.ts index b8a62629937..d2425e11012 100644 --- a/src/vs/base/common/observableInternal/autorun.ts +++ b/src/vs/base/common/observableInternal/autorun.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IChangeContext, IObservable, IObserver, IReader } from './base.js'; +import { IChangeContext, IObservable, IObservableWithChange, IObserver, IReader } from './base.js'; import { DebugNameData, IDebugNameData } from './debugName.js'; import { assertFn, BugIndicatingError, DisposableStore, IDisposable, markAsDisposed, onBugIndicatingError, toDisposable, trackDisposable } from './commonFacade/deps.js'; import { getLogger } from './logging.js'; @@ -286,7 +286,7 @@ export class AutorunObserver implements IObserver, IReader } } - public handleChange(observable: IObservable, change: TChange): void { + public handleChange(observable: IObservableWithChange, change: TChange): void { if (this.dependencies.has(observable) && !this.dependenciesToBeRemoved.has(observable)) { try { const shouldReact = this._handleChange ? this._handleChange({ diff --git a/src/vs/base/common/observableInternal/base.ts b/src/vs/base/common/observableInternal/base.ts index c28e773b268..f2aa0466f78 100644 --- a/src/vs/base/common/observableInternal/base.ts +++ b/src/vs/base/common/observableInternal/base.ts @@ -9,6 +9,13 @@ import type { derivedOpts } from './derived.js'; import { getLogger, logObservable } from './logging.js'; import { keepObserved, recomputeInitiallyAndOnChange } from './utils.js'; +/** + * Represents an observable value. + * + * @template T The type of the values the observable can hold. + */ +export interface IObservable extends IObservableWithChange { } + /** * Represents an observable value. * @@ -18,7 +25,7 @@ import { keepObserved, recomputeInitiallyAndOnChange } from './utils.js'; * While observers can miss temporary values of an observable, * they will receive all change values (as long as they are subscribed)! */ -export interface IObservable { +export interface IObservableWithChange { /** * Returns the current value. * @@ -71,7 +78,7 @@ export interface IObservable { * ONLY FOR DEBUGGING! * Logs computations of this derived. */ - log(): IObservable; + log(): IObservableWithChange; /** * Makes sure this value is computed eagerly. @@ -98,7 +105,7 @@ export interface IReader { /** * Reads the value of an observable and subscribes to it. */ - readObservable(observable: IObservable): T; + readObservable(observable: IObservableWithChange): T; } /** @@ -143,7 +150,7 @@ export interface IObserver { * * @param change Indicates how or why the value changed. */ - handleChange(observable: IObservable, change: TChange): void; + handleChange(observable: IObservableWithChange, change: TChange): void; } export interface ISettable { @@ -162,7 +169,7 @@ export interface ITransaction { * Calls {@link Observer.beginUpdate} immediately * and {@link Observer.endUpdate} when the transaction ends. */ - updateObserver(observer: IObserver, observable: IObservable): void; + updateObserver(observer: IObserver, observable: IObservableWithChange): void; } let _recomputeInitiallyAndOnChange: typeof recomputeInitiallyAndOnChange; @@ -185,7 +192,7 @@ export function _setDerivedOpts(derived: typeof _derived) { _derived = derived; } -export abstract class ConvenientObservable implements IObservable { +export abstract class ConvenientObservable implements IObservableWithChange { get TChange(): TChange { return null!; } public abstract get(): T; @@ -239,7 +246,7 @@ export abstract class ConvenientObservable implements IObservable { + public log(): IObservableWithChange { logObservable(this); return this; } @@ -248,7 +255,7 @@ export abstract class ConvenientObservable implements IObservable(this: IObservable>): IObservable { + public flatten(this: IObservable>): IObservable { return _derived( { owner: undefined, @@ -390,7 +397,7 @@ export class TransactionImpl implements ITransaction { /** * A settable observable. */ -export interface ISettableObservable extends IObservable, ISettable { +export interface ISettableObservable extends IObservableWithChange, ISettable { } /** @@ -505,11 +512,11 @@ export interface IChangeTracker { } export interface IChangeContext { - readonly changedObservable: IObservable; + readonly changedObservable: IObservableWithChange; readonly change: unknown; /** * Returns if the given observable caused the change. */ - didChange(observable: IObservable): this is { change: TChange }; + didChange(observable: IObservableWithChange): this is { change: TChange }; } diff --git a/src/vs/base/common/observableInternal/derived.ts b/src/vs/base/common/observableInternal/derived.ts index ba018041799..5421b023df9 100644 --- a/src/vs/base/common/observableInternal/derived.ts +++ b/src/vs/base/common/observableInternal/derived.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { BaseObservable, IChangeContext, IObservable, IObserver, IReader, ISettableObservable, ITransaction, _setDerivedOpts, } from './base.js'; +import { BaseObservable, IChangeContext, IObservable, IObservableWithChange, IObserver, IReader, ISettableObservable, ITransaction, _setDerivedOpts, } from './base.js'; import { DebugNameData, DebugOwner, IDebugNameData } from './debugName.js'; import { BugIndicatingError, DisposableStore, EqualityComparer, IDisposable, assertFn, onBugIndicatingError, strictEquals } from './commonFacade/deps.js'; import { getLogger } from './logging.js'; @@ -386,7 +386,7 @@ export class Derived extends BaseObservable im assertFn(() => this.updateCount >= 0); } - public handlePossibleChange(observable: IObservable): void { + public handlePossibleChange(observable: IObservable): void { // In all other states, observers already know that we might have changed. if (this.state === DerivedState.upToDate && this.dependencies.has(observable) && !this.dependenciesToBeRemoved.has(observable)) { this.state = DerivedState.dependenciesMightHaveChanged; @@ -396,7 +396,7 @@ export class Derived extends BaseObservable im } } - public handleChange(observable: IObservable, change: TChange): void { + public handleChange(observable: IObservableWithChange, change: TChange): void { if (this.dependencies.has(observable) && !this.dependenciesToBeRemoved.has(observable)) { let shouldReact = false; try { @@ -460,7 +460,7 @@ export class Derived extends BaseObservable im super.removeObserver(observer); } - public override log(): IObservable { + public override log(): IObservableWithChange { if (!getLogger()) { super.log(); getLogger()?.handleDerivedCreated(this); diff --git a/src/vs/base/common/observableInternal/index.ts b/src/vs/base/common/observableInternal/index.ts index 9295f2697d5..873cf946171 100644 --- a/src/vs/base/common/observableInternal/index.ts +++ b/src/vs/base/common/observableInternal/index.ts @@ -7,7 +7,7 @@ export { observableValueOpts } from './api.js'; export { autorun, autorunDelta, autorunHandleChanges, autorunOpts, autorunWithStore, autorunWithStoreHandleChanges } from './autorun.js'; -export { asyncTransaction, disposableObservableValue, globalTransaction, observableValue, subtransaction, transaction, TransactionImpl, type IChangeContext, type IChangeTracker, type IObservable, type IObserver, type IReader, type ISettable, type ISettableObservable, type ITransaction, } from './base.js'; +export { asyncTransaction, disposableObservableValue, globalTransaction, observableValue, subtransaction, transaction, TransactionImpl, type IChangeContext, type IChangeTracker, type IObservable, type IObservableWithChange, type IObserver, type IReader, type ISettable, type ISettableObservable, type ITransaction, } from './base.js'; export { derived, derivedDisposable, derivedHandleChanges, derivedOpts, derivedWithSetter, derivedWithStore } from './derived.js'; export { ObservableLazy, ObservableLazyPromise, ObservablePromise, PromiseResult, } from './promise.js'; export { derivedWithCancellationToken, waitForState } from './utilsCancellation.js'; diff --git a/src/vs/base/common/observableInternal/logging.ts b/src/vs/base/common/observableInternal/logging.ts index a6a5bb78a06..8dc526a45be 100644 --- a/src/vs/base/common/observableInternal/logging.ts +++ b/src/vs/base/common/observableInternal/logging.ts @@ -39,7 +39,7 @@ interface IChangeInformation { } export interface IObservableLogger { - handleObservableChanged(observable: IObservable, info: IChangeInformation): void; + handleObservableChanged(observable: IObservable, info: IChangeInformation): void; handleFromEventObservableTriggered(observable: FromEventObservable, info: IChangeInformation): void; handleAutorunCreated(autorun: AutorunObserver): void; @@ -101,7 +101,7 @@ export class ConsoleObservableLogger implements IObservableLogger { : [normalText(` (unchanged)`)]; } - handleObservableChanged(observable: IObservable, info: IChangeInformation): void { + handleObservableChanged(observable: IObservable, info: IChangeInformation): void { if (!this._isIncluded(observable)) { return; } console.log(...this.textToConsoleArgs([ formatKind('observable value changed'), @@ -110,9 +110,9 @@ export class ConsoleObservableLogger implements IObservableLogger { ])); } - private readonly changedObservablesSets = new WeakMap>>(); + private readonly changedObservablesSets = new WeakMap>>(); - formatChanges(changes: Set>): ConsoleText | undefined { + formatChanges(changes: Set>): ConsoleText | undefined { if (changes.size === 0) { return undefined; } diff --git a/src/vs/base/common/observableInternal/utils.ts b/src/vs/base/common/observableInternal/utils.ts index 2fb57d1a42a..c42f12f7b8e 100644 --- a/src/vs/base/common/observableInternal/utils.ts +++ b/src/vs/base/common/observableInternal/utils.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { autorun, autorunOpts, autorunWithStoreHandleChanges } from './autorun.js'; -import { BaseObservable, ConvenientObservable, IObservable, IObserver, IReader, ITransaction, _setKeepObserved, _setRecomputeInitiallyAndOnChange, observableValue, subtransaction, transaction } from './base.js'; +import { BaseObservable, ConvenientObservable, IObservable, IObservableWithChange, IObserver, IReader, ITransaction, _setKeepObserved, _setRecomputeInitiallyAndOnChange, observableValue, subtransaction, transaction } from './base.js'; import { DebugNameData, DebugOwner, IDebugNameData, getDebugName, } from './debugName.js'; import { BugIndicatingError, DisposableStore, EqualityComparer, Event, IDisposable, IValueWithChangeEvent, strictEquals, toDisposable } from './commonFacade/deps.js'; import { derived, derivedOpts } from './derived.js'; @@ -259,7 +259,7 @@ export function observableSignal(debugNameOrOwner: string | objec } } -export interface IObservableSignal extends IObservable { +export interface IObservableSignal extends IObservableWithChange { trigger(tx: ITransaction | undefined, change: TChange): void; } @@ -434,11 +434,11 @@ export class KeepAliveObserver implements IObserver { private readonly _handleValue: ((value: any) => void) | undefined, ) { } - beginUpdate(observable: IObservable): void { + beginUpdate(observable: IObservable): void { this._counter++; } - endUpdate(observable: IObservable): void { + endUpdate(observable: IObservable): void { this._counter--; if (this._counter === 0 && this._forceRecompute) { if (this._handleValue) { @@ -449,11 +449,11 @@ export class KeepAliveObserver implements IObserver { } } - handlePossibleChange(observable: IObservable): void { + handlePossibleChange(observable: IObservable): void { // NO OP } - handleChange(observable: IObservable, change: TChange): void { + handleChange(observable: IObservableWithChange, change: TChange): void { // NO OP } } @@ -625,7 +625,7 @@ export function derivedConstOnceDefined(owner: DebugOwner, fn: (reader: IRead type RemoveUndefined = T extends undefined ? never : T; -export function runOnChange(observable: IObservable, cb: (value: T, previousValue: undefined | T, deltas: RemoveUndefined[]) => void): IDisposable { +export function runOnChange(observable: IObservableWithChange, cb: (value: T, previousValue: undefined | T, deltas: RemoveUndefined[]) => void): IDisposable { let _previousValue: T | undefined; return autorunWithStoreHandleChanges({ createEmptyChangeSummary: () => ({ deltas: [] as RemoveUndefined[], didChange: false }), @@ -649,7 +649,7 @@ export function runOnChange(observable: IObservable, cb: }); } -export function runOnChangeWithStore(observable: IObservable, cb: (value: T, previousValue: undefined | T, deltas: RemoveUndefined[], store: DisposableStore) => void): IDisposable { +export function runOnChangeWithStore(observable: IObservableWithChange, cb: (value: T, previousValue: undefined | T, deltas: RemoveUndefined[], store: DisposableStore) => void): IDisposable { const store = new DisposableStore(); const disposable = runOnChange(observable, (value, previousValue: undefined | T, deltas) => { store.clear(); diff --git a/src/vs/base/test/common/observable.test.ts b/src/vs/base/test/common/observable.test.ts index 3d7ed472fcd..5d33ac30a9c 100644 --- a/src/vs/base/test/common/observable.test.ts +++ b/src/vs/base/test/common/observable.test.ts @@ -8,7 +8,7 @@ import { setUnexpectedErrorHandler } from '../../common/errors.js'; import { Emitter, Event } from '../../common/event.js'; import { DisposableStore } from '../../common/lifecycle.js'; import { autorun, autorunHandleChanges, derived, derivedDisposable, IObservable, IObserver, ISettableObservable, ITransaction, keepObserved, observableFromEvent, observableSignal, observableValue, transaction, waitForState } from '../../common/observable.js'; -import { BaseObservable } from '../../common/observableInternal/base.js'; +import { BaseObservable, IObservableWithChange } from '../../common/observableInternal/base.js'; import { ensureNoDisposablesAreLeakedInTestSuite } from './utils.js'; suite('observables', () => { @@ -1486,18 +1486,18 @@ export class LoggingObserver implements IObserver { constructor(public readonly debugName: string, private readonly log: Log) { } - beginUpdate(observable: IObservable): void { + beginUpdate(observable: IObservable): void { this.count++; this.log.log(`${this.debugName}.beginUpdate (count ${this.count})`); } - endUpdate(observable: IObservable): void { + endUpdate(observable: IObservable): void { this.log.log(`${this.debugName}.endUpdate (count ${this.count})`); this.count--; } - handleChange(observable: IObservable, change: TChange): void { + handleChange(observable: IObservableWithChange, change: TChange): void { this.log.log(`${this.debugName}.handleChange (count ${this.count})`); } - handlePossibleChange(observable: IObservable): void { + handlePossibleChange(observable: IObservable): void { this.log.log(`${this.debugName}.handlePossibleChange`); } } diff --git a/src/vs/editor/browser/observableCodeEditor.ts b/src/vs/editor/browser/observableCodeEditor.ts index 3633d4cac45..ac1ab182fa4 100644 --- a/src/vs/editor/browser/observableCodeEditor.ts +++ b/src/vs/editor/browser/observableCodeEditor.ts @@ -5,7 +5,7 @@ import { equalsIfDefined, itemsEquals } from '../../base/common/equals.js'; import { Disposable, DisposableStore, IDisposable, toDisposable } from '../../base/common/lifecycle.js'; -import { IObservable, ITransaction, TransactionImpl, autorun, autorunOpts, derived, derivedOpts, derivedWithSetter, observableFromEvent, observableSignal, observableValue, observableValueOpts } from '../../base/common/observable.js'; +import { IObservable, IObservableWithChange, ITransaction, TransactionImpl, autorun, autorunOpts, derived, derivedOpts, derivedWithSetter, observableFromEvent, observableSignal, observableValue, observableValueOpts } from '../../base/common/observable.js'; import { EditorOption, FindComputedEditorOptionValueById } from '../common/config/editorOptions.js'; import { LineRange } from '../common/core/lineRange.js'; import { OffsetRange } from '../common/core/offsetRange.js'; @@ -155,13 +155,13 @@ export class ObservableCodeEditor extends Disposable { public readonly isReadonly = observableFromEvent(this, this.editor.onDidChangeConfiguration, () => this.editor.getOption(EditorOption.readOnly)); private readonly _versionId = observableValueOpts({ owner: this, lazy: true }, this.editor.getModel()?.getVersionId() ?? null); - public readonly versionId: IObservable = this._versionId; + public readonly versionId: IObservableWithChange = this._versionId; private readonly _selections = observableValueOpts( { owner: this, equalsFn: equalsIfDefined(itemsEquals(Selection.selectionsEqual)), lazy: true }, this.editor.getSelections() ?? null ); - public readonly selections: IObservable = this._selections; + public readonly selections: IObservableWithChange = this._selections; public readonly positions = derivedOpts( diff --git a/src/vs/editor/browser/widget/diffEditor/components/diffEditorSash.ts b/src/vs/editor/browser/widget/diffEditor/components/diffEditorSash.ts index 8abaddcceb9..468e6323c7f 100644 --- a/src/vs/editor/browser/widget/diffEditor/components/diffEditorSash.ts +++ b/src/vs/editor/browser/widget/diffEditor/components/diffEditorSash.ts @@ -62,7 +62,7 @@ export class DiffEditorSash extends Disposable { private readonly _domNode: HTMLElement, private readonly _dimensions: { height: IObservable; width: IObservable }, private readonly _enabled: IObservable, - private readonly _boundarySashes: IObservable, + private readonly _boundarySashes: IObservable, public readonly sashLeft: ISettableObservable, private readonly _resetSash: () => void, ) { diff --git a/src/vs/editor/browser/widget/diffEditor/diffEditorOptions.ts b/src/vs/editor/browser/widget/diffEditor/diffEditorOptions.ts index 0c1a533681f..3d2e483ca15 100644 --- a/src/vs/editor/browser/widget/diffEditor/diffEditorOptions.ts +++ b/src/vs/editor/browser/widget/diffEditor/diffEditorOptions.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IObservable, ISettableObservable, derived, derivedConstOnceDefined, observableFromEvent, observableValue } from '../../../../base/common/observable.js'; +import { IObservable, IObservableWithChange, ISettableObservable, derived, derivedConstOnceDefined, observableFromEvent, observableValue } from '../../../../base/common/observable.js'; import { Constants } from '../../../../base/common/uint.js'; import { IAccessibilityService } from '../../../../platform/accessibility/common/accessibility.js'; import { diffEditorDefaultOptions } from '../../../common/config/diffEditor.js'; @@ -15,7 +15,7 @@ import { DiffEditorViewModel, DiffState } from './diffEditorViewModel.js'; export class DiffEditorOptions { private readonly _options: ISettableObservable, { changedOptions: IDiffEditorOptions }>; - public get editorOptions(): IObservable { return this._options; } + public get editorOptions(): IObservableWithChange { return this._options; } private readonly _diffEditorWidth = observableValue(this, 0); diff --git a/src/vs/editor/browser/widget/diffEditor/features/gutterFeature.ts b/src/vs/editor/browser/widget/diffEditor/features/gutterFeature.ts index 556378aebf3..17ff41896b4 100644 --- a/src/vs/editor/browser/widget/diffEditor/features/gutterFeature.ts +++ b/src/vs/editor/browser/widget/diffEditor/features/gutterFeature.ts @@ -50,7 +50,7 @@ export class DiffEditorGutter extends Disposable { private readonly _editors: DiffEditorEditors, private readonly _options: DiffEditorOptions, private readonly _sashLayout: SashLayout, - private readonly _boundarySashes: IObservable, + private readonly _boundarySashes: IObservable, @IInstantiationService private readonly _instantiationService: IInstantiationService, @IContextKeyService private readonly _contextKeyService: IContextKeyService, @IMenuService private readonly _menuService: IMenuService, diff --git a/src/vs/editor/browser/widget/diffEditor/utils.ts b/src/vs/editor/browser/widget/diffEditor/utils.ts index d34d60fd457..47faca2f8cf 100644 --- a/src/vs/editor/browser/widget/diffEditor/utils.ts +++ b/src/vs/editor/browser/widget/diffEditor/utils.ts @@ -7,7 +7,7 @@ import { IDimension } from '../../../../base/browser/dom.js'; import { findLast } from '../../../../base/common/arraysFind.js'; import { CancellationTokenSource } from '../../../../base/common/cancellation.js'; import { Disposable, DisposableStore, IDisposable, IReference, toDisposable } from '../../../../base/common/lifecycle.js'; -import { IObservable, ISettableObservable, autorun, autorunHandleChanges, autorunOpts, autorunWithStore, observableValue, transaction } from '../../../../base/common/observable.js'; +import { IObservable, IObservableWithChange, ISettableObservable, autorun, autorunHandleChanges, autorunOpts, autorunWithStore, observableValue, transaction } from '../../../../base/common/observable.js'; import { ElementSizeObserver } from '../../config/elementSizeObserver.js'; import { ICodeEditor, IOverlayWidget, IViewZone } from '../../editorBrowser.js'; import { Position } from '../../../common/core/position.js'; @@ -126,7 +126,7 @@ export class ObservableElementSizeObserver extends Disposable { } } -export function animatedObservable(targetWindow: Window, base: IObservable, store: DisposableStore): IObservable { +export function animatedObservable(targetWindow: Window, base: IObservableWithChange, store: DisposableStore): IObservable { let targetVal = base.get(); let startVal = targetVal; let curVal = targetVal; diff --git a/src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.ts b/src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.ts index a15005e75fa..b77a2c0df81 100644 --- a/src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.ts +++ b/src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.ts @@ -7,7 +7,7 @@ import { mapFindFirst } from '../../../../../base/common/arraysFind.js'; import { itemsEquals } from '../../../../../base/common/equals.js'; import { BugIndicatingError, onUnexpectedError, onUnexpectedExternalError } from '../../../../../base/common/errors.js'; import { Disposable } from '../../../../../base/common/lifecycle.js'; -import { IObservable, IReader, ITransaction, autorun, derived, derivedHandleChanges, derivedOpts, observableSignal, observableValue, recomputeInitiallyAndOnChange, subtransaction, transaction } from '../../../../../base/common/observable.js'; +import { IObservable, IObservableWithChange, IReader, ITransaction, autorun, derived, derivedHandleChanges, derivedOpts, observableSignal, observableValue, recomputeInitiallyAndOnChange, subtransaction, transaction } from '../../../../../base/common/observable.js'; import { commonPrefixLength, firstNonWhitespaceIndex } from '../../../../../base/common/strings.js'; import { isDefined } from '../../../../../base/common/types.js'; import { ICommandService } from '../../../../../platform/commands/common/commands.js'; @@ -63,7 +63,7 @@ export class InlineCompletionsModel extends Disposable { constructor( public readonly textModel: ITextModel, private readonly _selectedSuggestItem: IObservable, - public readonly _textModelVersionId: IObservable, + public readonly _textModelVersionId: IObservableWithChange, private readonly _positions: IObservable, private readonly _debounceValue: IFeatureDebounceInformation, private readonly _enabled: IObservable, diff --git a/src/vs/editor/test/browser/widget/observableCodeEditor.test.ts b/src/vs/editor/test/browser/widget/observableCodeEditor.test.ts index d9144896afe..e8406d868f8 100644 --- a/src/vs/editor/test/browser/widget/observableCodeEditor.test.ts +++ b/src/vs/editor/test/browser/widget/observableCodeEditor.test.ts @@ -112,7 +112,7 @@ suite("CodeEditorWidget", () => { })); test("listener interaction (unforced)", () => { - let derived: IObservable; + let derived: IObservable; let log: Log; withEditorSetupTestFixture( (editor, disposables) => { @@ -143,7 +143,7 @@ suite("CodeEditorWidget", () => { }); test("listener interaction ()", () => { - let derived: IObservable; + let derived: IObservable; let log: Log; withEditorSetupTestFixture( (editor, disposables) => { diff --git a/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.ts b/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.ts index 63512ae0e38..2741b6681d4 100644 --- a/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.ts +++ b/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.ts @@ -12,7 +12,7 @@ import { LineRangeEdit } from './editing.js'; import { LineRange } from './lineRange.js'; import { ReentrancyBarrier } from '../../../../../base/common/controlFlow.js'; import { IMergeDiffComputer } from './diffComputer.js'; -import { autorun, IObservable, IReader, ITransaction, observableSignal, observableValue, transaction } from '../../../../../base/common/observable.js'; +import { autorun, IObservableWithChange, IReader, ITransaction, observableSignal, observableValue, transaction } from '../../../../../base/common/observable.js'; import { UndoRedoGroup } from '../../../../../platform/undoRedo/common/undoRedo.js'; export class TextModelDiffs extends Disposable { @@ -61,14 +61,14 @@ export class TextModelDiffs extends Disposable { })); } - public get state(): IObservable { + public get state(): IObservableWithChange { return this._state; } /** * Diffs from base to input. */ - public get diffs(): IObservable { + public get diffs(): IObservableWithChange { return this._diffs; } diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatActionsOverlay.ts b/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatActionsOverlay.ts index 552a657df4d..7ac61fbcb30 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatActionsOverlay.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatActionsOverlay.ts @@ -24,7 +24,7 @@ import { navigationBearingFakeActionId } from '../../../../chat/browser/chatEdit export class NotebookChatActionsOverlayController extends Disposable { constructor( private readonly notebookEditor: INotebookEditor, - cellDiffInfo: IObservable, + cellDiffInfo: IObservable, deletedCellDecorator: INotebookDeletedCellDecorator, @IChatEditingService private readonly _chatEditingService: IChatEditingService, @IInstantiationService instantiationService: IInstantiationService, @@ -60,7 +60,7 @@ export class NotebookChatActionsOverlay extends Disposable { constructor( private readonly notebookEditor: INotebookEditor, entry: IModifiedFileEntry, - cellDiffInfo: IObservable, + cellDiffInfo: IObservable, nextEntry: IModifiedFileEntry, previousEntry: IModifiedFileEntry, deletedCellDecorator: INotebookDeletedCellDecorator, @@ -196,7 +196,7 @@ export class NotebookChatActionsOverlay extends Disposable { class NextPreviousChangeActionRunner extends ActionRunner { constructor( private readonly notebookEditor: INotebookEditor, - private readonly cellDiffInfo: IObservable, + private readonly cellDiffInfo: IObservable, private readonly entry: IModifiedFileEntry, private readonly next: IModifiedFileEntry, private readonly direction: 'next' | 'previous', diff --git a/src/vs/workbench/contrib/testing/common/observableUtils.ts b/src/vs/workbench/contrib/testing/common/observableUtils.ts index 3153f2e5bd8..9294c905002 100644 --- a/src/vs/workbench/contrib/testing/common/observableUtils.ts +++ b/src/vs/workbench/contrib/testing/common/observableUtils.ts @@ -4,16 +4,16 @@ *--------------------------------------------------------------------------------------------*/ import { IDisposable } from '../../../../base/common/lifecycle.js'; -import { IObservable, IObserver } from '../../../../base/common/observable.js'; +import { IObservableWithChange, IObserver } from '../../../../base/common/observable.js'; -export function onObservableChange(observable: IObservable, callback: (value: T) => void): IDisposable { +export function onObservableChange(observable: IObservableWithChange, callback: (value: T) => void): IDisposable { const o: IObserver = { beginUpdate() { }, endUpdate() { }, handlePossibleChange(observable) { observable.reportChanges(); }, - handleChange(_observable: IObservable, change: TChange) { + handleChange(_observable: IObservableWithChange, change: TChange) { callback(change as any as T); } };