monaco-editor-core 0.54.0-dev-20250911 → 0.54.0-dev-20250913
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/nls.messages.de.js +1 -1
- package/esm/nls.messages.es.js +1 -1
- package/esm/nls.messages.fr.js +1 -1
- package/esm/nls.messages.it.js +1 -1
- package/esm/nls.messages.ja.js +1 -1
- package/esm/nls.messages.ko.js +1 -1
- package/esm/nls.messages.ru.js +1 -1
- package/esm/nls.messages.zh-cn.js +1 -1
- package/esm/nls.messages.zh-tw.js +1 -1
- package/esm/vs/base/browser/ui/codicons/codicon/codicon.ttf +0 -0
- package/esm/vs/base/browser/ui/menu/menu.js +2 -0
- package/esm/vs/base/browser/ui/menu/menu.js.map +1 -1
- package/esm/vs/base/common/observableInternal/index.js +3 -0
- package/esm/vs/base/common/observableInternal/index.js.map +1 -1
- package/esm/vs/base/common/observableInternal/logging/debugGetDependencyGraph.js +71 -0
- package/esm/vs/base/common/observableInternal/logging/debugGetDependencyGraph.js.map +1 -0
- package/esm/vs/base/common/observableInternal/observables/baseObservable.js +4 -0
- package/esm/vs/base/common/observableInternal/observables/baseObservable.js.map +1 -1
- package/esm/vs/base/common/observableInternal/observables/derivedImpl.js +10 -0
- package/esm/vs/base/common/observableInternal/observables/derivedImpl.js.map +1 -1
- package/esm/vs/base/common/observableInternal/observables/observableFromEvent.js +3 -0
- package/esm/vs/base/common/observableInternal/observables/observableFromEvent.js.map +1 -1
- package/esm/vs/base/common/observableInternal/reactions/autorunImpl.js +9 -0
- package/esm/vs/base/common/observableInternal/reactions/autorunImpl.js.map +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/commands.js +12 -1
- package/esm/vs/editor/browser/widget/diffEditor/commands.js.map +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/diffEditorWidget.js +25 -0
- package/esm/vs/editor/browser/widget/diffEditor/diffEditorWidget.js.map +1 -1
- package/esm/vs/editor/common/core/ranges/lineRange.js +3 -0
- package/esm/vs/editor/common/core/ranges/lineRange.js.map +1 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorView.js +4 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorView.js.map +1 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.js +2 -0
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.js.map +1 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViewProducer.js +1 -0
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViewProducer.js.map +1 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/theme.js +2 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/theme.js.map +1 -1
- package/esm/vs/platform/actionWidget/browser/actionList.js +3 -0
- package/esm/vs/platform/actionWidget/browser/actionList.js.map +1 -1
- package/esm/vs/platform/quickinput/browser/quickInput.js +2 -2
- package/esm/vs/platform/quickinput/browser/quickInput.js.map +1 -1
- package/esm/vs/platform/quickinput/browser/quickInputController.js +4 -0
- package/esm/vs/platform/quickinput/browser/quickInputController.js.map +1 -1
- package/esm/vs/platform/quickinput/browser/tree/quickInputTreeController.js +12 -0
- package/esm/vs/platform/quickinput/browser/tree/quickInputTreeController.js.map +1 -1
- package/esm/vs/platform/quickinput/browser/tree/quickInputTreeRenderer.js +11 -5
- package/esm/vs/platform/quickinput/browser/tree/quickInputTreeRenderer.js.map +1 -1
- package/esm/vs/platform/quickinput/common/quickInput.js.map +1 -1
- package/package.json +6 -2
- package/version.txt +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/observableInternal/reactions/autorunImpl.ts","vs/base/common/observableInternal/reactions/autorunImpl.ts"],"names":[],"mappings":"A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;YACpB,MAAM,IAAI,kBAAkB,CAAC,mCAAmC,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAIM,aAAa;QACnB,OAAO;YACN,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,WAAW,EAAE,IAAI,CAAC,YAAY;YAC9B,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,KAAK,EAAE,IAAI,CAAC,MAAM;SAClB,CAAC;IACH,CAAC;IAEM,UAAU;QAChB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,EAAE,CAAC;QACb,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,MAAM,6BAAqB,CAAC;QAClC,CAAC;IACF,CAAC;CACD","file":"autorunImpl.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IObservable, IObservableWithChange, IObserver, IReaderWithStore } from '../base.js';\nimport { DebugNameData } from '../debugName.js';\nimport { assertFn, BugIndicatingError, DisposableStore, IDisposable, markAsDisposed, onBugIndicatingError, trackDisposable } from '../commonFacade/deps.js';\nimport { getLogger } from '../logging/logging.js';\nimport { IChangeTracker } from '../changeTracker.js';\nimport { DebugLocation } from '../debugLocation.js';\n\nexport const enum AutorunState {\n\t/**\n\t * A dependency could have changed.\n\t * We need to explicitly ask them if at least one dependency changed.\n\t */\n\tdependenciesMightHaveChanged = 1,\n\n\t/**\n\t * A dependency changed and we need to recompute.\n\t */\n\tstale = 2,\n\tupToDate = 3,\n}\n\nexport class AutorunObserver<TChangeSummary = any> implements IObserver, IReaderWithStore, IDisposable {\n\tprivate _state = AutorunState.stale;\n\tprivate _updateCount = 0;\n\tprivate _disposed = false;\n\tprivate _dependencies = new Set<IObservable<any>>();\n\tprivate _dependenciesToBeRemoved = new Set<IObservable<any>>();\n\tprivate _changeSummary: TChangeSummary | undefined;\n\tprivate _isRunning = false;\n\n\tpublic get debugName(): string {\n\t\treturn this._debugNameData.getDebugName(this) ?? '(anonymous)';\n\t}\n\n\tconstructor(\n\t\tpublic readonly _debugNameData: DebugNameData,\n\t\tpublic readonly _runFn: (reader: IReaderWithStore, changeSummary: TChangeSummary) => void,\n\t\tprivate readonly _changeTracker: IChangeTracker<TChangeSummary> | undefined,\n\t\tdebugLocation: DebugLocation\n\t) {\n\t\tthis._changeSummary = this._changeTracker?.createChangeSummary(undefined);\n\t\tgetLogger()?.handleAutorunCreated(this, debugLocation);\n\t\tthis._run();\n\n\t\ttrackDisposable(this);\n\t}\n\n\tpublic dispose(): void {\n\t\tif (this._disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis._disposed = true;\n\t\tfor (const o of this._dependencies) {\n\t\t\to.removeObserver(this); // Warning: external call!\n\t\t}\n\t\tthis._dependencies.clear();\n\n\t\tif (this._store !== undefined) {\n\t\t\tthis._store.dispose();\n\t\t}\n\t\tif (this._delayedStore !== undefined) {\n\t\t\tthis._delayedStore.dispose();\n\t\t}\n\n\t\tgetLogger()?.handleAutorunDisposed(this);\n\t\tmarkAsDisposed(this);\n\t}\n\n\tprivate _run() {\n\t\tconst emptySet = this._dependenciesToBeRemoved;\n\t\tthis._dependenciesToBeRemoved = this._dependencies;\n\t\tthis._dependencies = emptySet;\n\n\t\tthis._state = AutorunState.upToDate;\n\n\t\ttry {\n\t\t\tif (!this._disposed) {\n\t\t\t\tgetLogger()?.handleAutorunStarted(this);\n\t\t\t\tconst changeSummary = this._changeSummary!;\n\t\t\t\tconst delayedStore = this._delayedStore;\n\t\t\t\tif (delayedStore !== undefined) {\n\t\t\t\t\tthis._delayedStore = undefined;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tthis._isRunning = true;\n\t\t\t\t\tif (this._changeTracker) {\n\t\t\t\t\t\tthis._changeTracker.beforeUpdate?.(this, changeSummary);\n\t\t\t\t\t\tthis._changeSummary = this._changeTracker.createChangeSummary(changeSummary); // Warning: external call!\n\t\t\t\t\t}\n\t\t\t\t\tif (this._store !== undefined) {\n\t\t\t\t\t\tthis._store.dispose();\n\t\t\t\t\t\tthis._store = undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runFn(this, changeSummary); // Warning: external call!\n\t\t\t\t} catch (e) {\n\t\t\t\t\tonBugIndicatingError(e);\n\t\t\t\t} finally {\n\t\t\t\t\tthis._isRunning = false;\n\t\t\t\t\tif (delayedStore !== undefined) {\n\t\t\t\t\t\tdelayedStore.dispose();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tif (!this._disposed) {\n\t\t\t\tgetLogger()?.handleAutorunFinished(this);\n\t\t\t}\n\t\t\t// We don't want our observed observables to think that they are (not even temporarily) not being observed.\n\t\t\t// Thus, we only unsubscribe from observables that are definitely not read anymore.\n\t\t\tfor (const o of this._dependenciesToBeRemoved) {\n\t\t\t\to.removeObserver(this); // Warning: external call!\n\t\t\t}\n\t\t\tthis._dependenciesToBeRemoved.clear();\n\t\t}\n\t}\n\n\tpublic toString(): string {\n\t\treturn `Autorun<${this.debugName}>`;\n\t}\n\n\t// IObserver implementation\n\tpublic beginUpdate(_observable: IObservable<any>): void {\n\t\tif (this._state === AutorunState.upToDate) {\n\t\t\tthis._state = AutorunState.dependenciesMightHaveChanged;\n\t\t}\n\t\tthis._updateCount++;\n\t}\n\n\tpublic endUpdate(_observable: IObservable<any>): void {\n\t\ttry {\n\t\t\tif (this._updateCount === 1) {\n\t\t\t\tdo {\n\t\t\t\t\tif (this._state === AutorunState.dependenciesMightHaveChanged) {\n\t\t\t\t\t\tthis._state = AutorunState.upToDate;\n\t\t\t\t\t\tfor (const d of this._dependencies) {\n\t\t\t\t\t\t\td.reportChanges(); // Warning: external call!\n\t\t\t\t\t\t\tif (this._state as AutorunState === AutorunState.stale) {\n\t\t\t\t\t\t\t\t// The other dependencies will refresh on demand\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._state !== AutorunState.upToDate) {\n\t\t\t\t\t\tthis._run(); // Warning: indirect external call!\n\t\t\t\t\t}\n\t\t\t\t} while (this._state !== AutorunState.upToDate);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._updateCount--;\n\t\t}\n\n\t\tassertFn(() => this._updateCount >= 0);\n\t}\n\n\tpublic handlePossibleChange(observable: IObservable<any>): void {\n\t\tif (this._state === AutorunState.upToDate && this._isDependency(observable)) {\n\t\t\tthis._state = AutorunState.dependenciesMightHaveChanged;\n\t\t}\n\t}\n\n\tpublic handleChange<T, TChange>(observable: IObservableWithChange<T, TChange>, change: TChange): void {\n\t\tif (this._isDependency(observable)) {\n\t\t\tgetLogger()?.handleAutorunDependencyChanged(this, observable, change);\n\t\t\ttry {\n\t\t\t\t// Warning: external call!\n\t\t\t\tconst shouldReact = this._changeTracker ? this._changeTracker.handleChange({\n\t\t\t\t\tchangedObservable: observable,\n\t\t\t\t\tchange,\n\t\t\t\t\tdidChange: (o): this is any => o === observable as any,\n\t\t\t\t}, this._changeSummary!) : true;\n\t\t\t\tif (shouldReact) {\n\t\t\t\t\tthis._state = AutorunState.stale;\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tonBugIndicatingError(e);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _isDependency(observable: IObservableWithChange<any, any>): boolean {\n\t\treturn this._dependencies.has(observable) && !this._dependenciesToBeRemoved.has(observable);\n\t}\n\n\t// IReader implementation\n\n\tprivate _ensureNoRunning(): void {\n\t\tif (!this._isRunning) { throw new BugIndicatingError('The reader object cannot be used outside its compute function!'); }\n\t}\n\n\tpublic readObservable<T>(observable: IObservable<T>): T {\n\t\tthis._ensureNoRunning();\n\n\t\t// In case the run action disposes the autorun\n\t\tif (this._disposed) {\n\t\t\treturn observable.get(); // warning: external call!\n\t\t}\n\n\t\tobservable.addObserver(this); // warning: external call!\n\t\tconst value = observable.get(); // warning: external call!\n\t\tthis._dependencies.add(observable);\n\t\tthis._dependenciesToBeRemoved.delete(observable);\n\t\treturn value;\n\t}\n\n\tprivate _store: DisposableStore | undefined = undefined;\n\tget store(): DisposableStore {\n\t\tthis._ensureNoRunning();\n\t\tif (this._disposed) {\n\t\t\tthrow new BugIndicatingError('Cannot access store after dispose');\n\t\t}\n\n\t\tif (this._store === undefined) {\n\t\t\tthis._store = new DisposableStore();\n\t\t}\n\t\treturn this._store;\n\t}\n\n\tprivate _delayedStore: DisposableStore | undefined = undefined;\n\n\tpublic debugGetState() {\n\t\treturn {\n\t\t\tisRunning: this._isRunning,\n\t\t\tupdateCount: this._updateCount,\n\t\t\tdependencies: this._dependencies,\n\t\t\tstate: this._state,\n\t\t};\n\t}\n\n\tpublic debugRerun(): void {\n\t\tif (!this._isRunning) {\n\t\t\tthis._run();\n\t\t} else {\n\t\t\tthis._state = AutorunState.stale;\n\t\t}\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IObservable, IObservableWithChange, IObserver, IReaderWithStore } from '../base.js';\nimport { DebugNameData } from '../debugName.js';\nimport { assertFn, BugIndicatingError, DisposableStore, IDisposable, markAsDisposed, onBugIndicatingError, trackDisposable } from '../commonFacade/deps.js';\nimport { getLogger } from '../logging/logging.js';\nimport { IChangeTracker } from '../changeTracker.js';\nimport { DebugLocation } from '../debugLocation.js';\n\nexport const enum AutorunState {\n\t/**\n\t * A dependency could have changed.\n\t * We need to explicitly ask them if at least one dependency changed.\n\t */\n\tdependenciesMightHaveChanged = 1,\n\n\t/**\n\t * A dependency changed and we need to recompute.\n\t */\n\tstale = 2,\n\tupToDate = 3,\n}\n\nexport class AutorunObserver<TChangeSummary = any> implements IObserver, IReaderWithStore, IDisposable {\n\tprivate _state = AutorunState.stale;\n\tprivate _updateCount = 0;\n\tprivate _disposed = false;\n\tprivate _dependencies = new Set<IObservable<any>>();\n\tprivate _dependenciesToBeRemoved = new Set<IObservable<any>>();\n\tprivate _changeSummary: TChangeSummary | undefined;\n\tprivate _isRunning = false;\n\n\tpublic get debugName(): string {\n\t\treturn this._debugNameData.getDebugName(this) ?? '(anonymous)';\n\t}\n\n\tconstructor(\n\t\tpublic readonly _debugNameData: DebugNameData,\n\t\tpublic readonly _runFn: (reader: IReaderWithStore, changeSummary: TChangeSummary) => void,\n\t\tprivate readonly _changeTracker: IChangeTracker<TChangeSummary> | undefined,\n\t\tdebugLocation: DebugLocation\n\t) {\n\t\tthis._changeSummary = this._changeTracker?.createChangeSummary(undefined);\n\t\tgetLogger()?.handleAutorunCreated(this, debugLocation);\n\t\tthis._run();\n\n\t\ttrackDisposable(this);\n\t}\n\n\tpublic dispose(): void {\n\t\tif (this._disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis._disposed = true;\n\t\tfor (const o of this._dependencies) {\n\t\t\to.removeObserver(this); // Warning: external call!\n\t\t}\n\t\tthis._dependencies.clear();\n\n\t\tif (this._store !== undefined) {\n\t\t\tthis._store.dispose();\n\t\t}\n\t\tif (this._delayedStore !== undefined) {\n\t\t\tthis._delayedStore.dispose();\n\t\t}\n\n\t\tgetLogger()?.handleAutorunDisposed(this);\n\t\tmarkAsDisposed(this);\n\t}\n\n\tprivate _run() {\n\t\tconst emptySet = this._dependenciesToBeRemoved;\n\t\tthis._dependenciesToBeRemoved = this._dependencies;\n\t\tthis._dependencies = emptySet;\n\n\t\tthis._state = AutorunState.upToDate;\n\n\t\ttry {\n\t\t\tif (!this._disposed) {\n\t\t\t\tgetLogger()?.handleAutorunStarted(this);\n\t\t\t\tconst changeSummary = this._changeSummary!;\n\t\t\t\tconst delayedStore = this._delayedStore;\n\t\t\t\tif (delayedStore !== undefined) {\n\t\t\t\t\tthis._delayedStore = undefined;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tthis._isRunning = true;\n\t\t\t\t\tif (this._changeTracker) {\n\t\t\t\t\t\tthis._changeTracker.beforeUpdate?.(this, changeSummary);\n\t\t\t\t\t\tthis._changeSummary = this._changeTracker.createChangeSummary(changeSummary); // Warning: external call!\n\t\t\t\t\t}\n\t\t\t\t\tif (this._store !== undefined) {\n\t\t\t\t\t\tthis._store.dispose();\n\t\t\t\t\t\tthis._store = undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runFn(this, changeSummary); // Warning: external call!\n\t\t\t\t} catch (e) {\n\t\t\t\t\tonBugIndicatingError(e);\n\t\t\t\t} finally {\n\t\t\t\t\tthis._isRunning = false;\n\t\t\t\t\tif (delayedStore !== undefined) {\n\t\t\t\t\t\tdelayedStore.dispose();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tif (!this._disposed) {\n\t\t\t\tgetLogger()?.handleAutorunFinished(this);\n\t\t\t}\n\t\t\t// We don't want our observed observables to think that they are (not even temporarily) not being observed.\n\t\t\t// Thus, we only unsubscribe from observables that are definitely not read anymore.\n\t\t\tfor (const o of this._dependenciesToBeRemoved) {\n\t\t\t\to.removeObserver(this); // Warning: external call!\n\t\t\t}\n\t\t\tthis._dependenciesToBeRemoved.clear();\n\t\t}\n\t}\n\n\tpublic toString(): string {\n\t\treturn `Autorun<${this.debugName}>`;\n\t}\n\n\t// IObserver implementation\n\tpublic beginUpdate(_observable: IObservable<any>): void {\n\t\tif (this._state === AutorunState.upToDate) {\n\t\t\tthis._state = AutorunState.dependenciesMightHaveChanged;\n\t\t}\n\t\tthis._updateCount++;\n\t}\n\n\tpublic endUpdate(_observable: IObservable<any>): void {\n\t\ttry {\n\t\t\tif (this._updateCount === 1) {\n\t\t\t\tdo {\n\t\t\t\t\tif (this._state === AutorunState.dependenciesMightHaveChanged) {\n\t\t\t\t\t\tthis._state = AutorunState.upToDate;\n\t\t\t\t\t\tfor (const d of this._dependencies) {\n\t\t\t\t\t\t\td.reportChanges(); // Warning: external call!\n\t\t\t\t\t\t\tif (this._state as AutorunState === AutorunState.stale) {\n\t\t\t\t\t\t\t\t// The other dependencies will refresh on demand\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._state !== AutorunState.upToDate) {\n\t\t\t\t\t\tthis._run(); // Warning: indirect external call!\n\t\t\t\t\t}\n\t\t\t\t} while (this._state !== AutorunState.upToDate);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._updateCount--;\n\t\t}\n\n\t\tassertFn(() => this._updateCount >= 0);\n\t}\n\n\tpublic handlePossibleChange(observable: IObservable<any>): void {\n\t\tif (this._state === AutorunState.upToDate && this._isDependency(observable)) {\n\t\t\tthis._state = AutorunState.dependenciesMightHaveChanged;\n\t\t}\n\t}\n\n\tpublic handleChange<T, TChange>(observable: IObservableWithChange<T, TChange>, change: TChange): void {\n\t\tif (this._isDependency(observable)) {\n\t\t\tgetLogger()?.handleAutorunDependencyChanged(this, observable, change);\n\t\t\ttry {\n\t\t\t\t// Warning: external call!\n\t\t\t\tconst shouldReact = this._changeTracker ? this._changeTracker.handleChange({\n\t\t\t\t\tchangedObservable: observable,\n\t\t\t\t\tchange,\n\t\t\t\t\tdidChange: (o): this is any => o === observable as any,\n\t\t\t\t}, this._changeSummary!) : true;\n\t\t\t\tif (shouldReact) {\n\t\t\t\t\tthis._state = AutorunState.stale;\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tonBugIndicatingError(e);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _isDependency(observable: IObservableWithChange<any, any>): boolean {\n\t\treturn this._dependencies.has(observable) && !this._dependenciesToBeRemoved.has(observable);\n\t}\n\n\t// IReader implementation\n\n\tprivate _ensureNoRunning(): void {\n\t\tif (!this._isRunning) { throw new BugIndicatingError('The reader object cannot be used outside its compute function!'); }\n\t}\n\n\tpublic readObservable<T>(observable: IObservable<T>): T {\n\t\tthis._ensureNoRunning();\n\n\t\t// In case the run action disposes the autorun\n\t\tif (this._disposed) {\n\t\t\treturn observable.get(); // warning: external call!\n\t\t}\n\n\t\tobservable.addObserver(this); // warning: external call!\n\t\tconst value = observable.get(); // warning: external call!\n\t\tthis._dependencies.add(observable);\n\t\tthis._dependenciesToBeRemoved.delete(observable);\n\t\treturn value;\n\t}\n\n\tprivate _store: DisposableStore | undefined = undefined;\n\tget store(): DisposableStore {\n\t\tthis._ensureNoRunning();\n\t\tif (this._disposed) {\n\t\t\tthrow new BugIndicatingError('Cannot access store after dispose');\n\t\t}\n\n\t\tif (this._store === undefined) {\n\t\t\tthis._store = new DisposableStore();\n\t\t}\n\t\treturn this._store;\n\t}\n\n\tprivate _delayedStore: DisposableStore | undefined = undefined;\n\n\tpublic debugGetState() {\n\t\treturn {\n\t\t\tisRunning: this._isRunning,\n\t\t\tupdateCount: this._updateCount,\n\t\t\tdependencies: this._dependencies,\n\t\t\tstate: this._state,\n\t\t};\n\t}\n\n\tpublic debugRerun(): void {\n\t\tif (!this._isRunning) {\n\t\t\tthis._run();\n\t\t} else {\n\t\t\tthis._state = AutorunState.stale;\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/observableInternal/reactions/autorunImpl.ts","vs/base/common/observableInternal/reactions/autorunImpl.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAe,cAAc,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC5J,OAAO,EAAE,SAAS,EAAE,MAAM,uB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D,IAAI,KAAK;QACR,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,kBAAkB,CAAC,mCAAmC,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAIM,aAAa;QACnB,OAAO;YACN,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,WAAW,EAAE,IAAI,CAAC,YAAY;YAC9B,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,QAAQ,EAAE,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC;SAC3C,CAAC;IACH,CAAC;IAEM,UAAU;QAChB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,EAAE,CAAC;QACb,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,MAAM,6BAAqB,CAAC;QAClC,CAAC;IACF,CAAC;CACD","file":"autorunImpl.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IObservable, IObservableWithChange, IObserver, IReaderWithStore } from '../base.js';\nimport { DebugNameData } from '../debugName.js';\nimport { assertFn, BugIndicatingError, DisposableStore, IDisposable, markAsDisposed, onBugIndicatingError, trackDisposable } from '../commonFacade/deps.js';\nimport { getLogger } from '../logging/logging.js';\nimport { IChangeTracker } from '../changeTracker.js';\nimport { DebugLocation } from '../debugLocation.js';\n\nexport const enum AutorunState {\n\t/**\n\t * A dependency could have changed.\n\t * We need to explicitly ask them if at least one dependency changed.\n\t */\n\tdependenciesMightHaveChanged = 1,\n\n\t/**\n\t * A dependency changed and we need to recompute.\n\t */\n\tstale = 2,\n\tupToDate = 3,\n}\n\nfunction autorunStateToString(state: AutorunState): string {\n\tswitch (state) {\n\t\tcase AutorunState.dependenciesMightHaveChanged: return 'dependenciesMightHaveChanged';\n\t\tcase AutorunState.stale: return 'stale';\n\t\tcase AutorunState.upToDate: return 'upToDate';\n\t\tdefault: return '<unknown>';\n\t}\n}\n\nexport class AutorunObserver<TChangeSummary = any> implements IObserver, IReaderWithStore, IDisposable {\n\tprivate _state = AutorunState.stale;\n\tprivate _updateCount = 0;\n\tprivate _disposed = false;\n\tprivate _dependencies = new Set<IObservable<any>>();\n\tprivate _dependenciesToBeRemoved = new Set<IObservable<any>>();\n\tprivate _changeSummary: TChangeSummary | undefined;\n\tprivate _isRunning = false;\n\n\tpublic get debugName(): string {\n\t\treturn this._debugNameData.getDebugName(this) ?? '(anonymous)';\n\t}\n\n\tconstructor(\n\t\tpublic readonly _debugNameData: DebugNameData,\n\t\tpublic readonly _runFn: (reader: IReaderWithStore, changeSummary: TChangeSummary) => void,\n\t\tprivate readonly _changeTracker: IChangeTracker<TChangeSummary> | undefined,\n\t\tdebugLocation: DebugLocation\n\t) {\n\t\tthis._changeSummary = this._changeTracker?.createChangeSummary(undefined);\n\t\tgetLogger()?.handleAutorunCreated(this, debugLocation);\n\t\tthis._run();\n\n\t\ttrackDisposable(this);\n\t}\n\n\tpublic dispose(): void {\n\t\tif (this._disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis._disposed = true;\n\t\tfor (const o of this._dependencies) {\n\t\t\to.removeObserver(this); // Warning: external call!\n\t\t}\n\t\tthis._dependencies.clear();\n\n\t\tif (this._store !== undefined) {\n\t\t\tthis._store.dispose();\n\t\t}\n\t\tif (this._delayedStore !== undefined) {\n\t\t\tthis._delayedStore.dispose();\n\t\t}\n\n\t\tgetLogger()?.handleAutorunDisposed(this);\n\t\tmarkAsDisposed(this);\n\t}\n\n\tprivate _run() {\n\t\tconst emptySet = this._dependenciesToBeRemoved;\n\t\tthis._dependenciesToBeRemoved = this._dependencies;\n\t\tthis._dependencies = emptySet;\n\n\t\tthis._state = AutorunState.upToDate;\n\n\t\ttry {\n\t\t\tif (!this._disposed) {\n\t\t\t\tgetLogger()?.handleAutorunStarted(this);\n\t\t\t\tconst changeSummary = this._changeSummary!;\n\t\t\t\tconst delayedStore = this._delayedStore;\n\t\t\t\tif (delayedStore !== undefined) {\n\t\t\t\t\tthis._delayedStore = undefined;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tthis._isRunning = true;\n\t\t\t\t\tif (this._changeTracker) {\n\t\t\t\t\t\tthis._changeTracker.beforeUpdate?.(this, changeSummary);\n\t\t\t\t\t\tthis._changeSummary = this._changeTracker.createChangeSummary(changeSummary); // Warning: external call!\n\t\t\t\t\t}\n\t\t\t\t\tif (this._store !== undefined) {\n\t\t\t\t\t\tthis._store.dispose();\n\t\t\t\t\t\tthis._store = undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runFn(this, changeSummary); // Warning: external call!\n\t\t\t\t} catch (e) {\n\t\t\t\t\tonBugIndicatingError(e);\n\t\t\t\t} finally {\n\t\t\t\t\tthis._isRunning = false;\n\t\t\t\t\tif (delayedStore !== undefined) {\n\t\t\t\t\t\tdelayedStore.dispose();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tif (!this._disposed) {\n\t\t\t\tgetLogger()?.handleAutorunFinished(this);\n\t\t\t}\n\t\t\t// We don't want our observed observables to think that they are (not even temporarily) not being observed.\n\t\t\t// Thus, we only unsubscribe from observables that are definitely not read anymore.\n\t\t\tfor (const o of this._dependenciesToBeRemoved) {\n\t\t\t\to.removeObserver(this); // Warning: external call!\n\t\t\t}\n\t\t\tthis._dependenciesToBeRemoved.clear();\n\t\t}\n\t}\n\n\tpublic toString(): string {\n\t\treturn `Autorun<${this.debugName}>`;\n\t}\n\n\t// IObserver implementation\n\tpublic beginUpdate(_observable: IObservable<any>): void {\n\t\tif (this._state === AutorunState.upToDate) {\n\t\t\tthis._state = AutorunState.dependenciesMightHaveChanged;\n\t\t}\n\t\tthis._updateCount++;\n\t}\n\n\tpublic endUpdate(_observable: IObservable<any>): void {\n\t\ttry {\n\t\t\tif (this._updateCount === 1) {\n\t\t\t\tdo {\n\t\t\t\t\tif (this._state === AutorunState.dependenciesMightHaveChanged) {\n\t\t\t\t\t\tthis._state = AutorunState.upToDate;\n\t\t\t\t\t\tfor (const d of this._dependencies) {\n\t\t\t\t\t\t\td.reportChanges(); // Warning: external call!\n\t\t\t\t\t\t\tif (this._state as AutorunState === AutorunState.stale) {\n\t\t\t\t\t\t\t\t// The other dependencies will refresh on demand\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._state !== AutorunState.upToDate) {\n\t\t\t\t\t\tthis._run(); // Warning: indirect external call!\n\t\t\t\t\t}\n\t\t\t\t} while (this._state !== AutorunState.upToDate);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._updateCount--;\n\t\t}\n\n\t\tassertFn(() => this._updateCount >= 0);\n\t}\n\n\tpublic handlePossibleChange(observable: IObservable<any>): void {\n\t\tif (this._state === AutorunState.upToDate && this._isDependency(observable)) {\n\t\t\tthis._state = AutorunState.dependenciesMightHaveChanged;\n\t\t}\n\t}\n\n\tpublic handleChange<T, TChange>(observable: IObservableWithChange<T, TChange>, change: TChange): void {\n\t\tif (this._isDependency(observable)) {\n\t\t\tgetLogger()?.handleAutorunDependencyChanged(this, observable, change);\n\t\t\ttry {\n\t\t\t\t// Warning: external call!\n\t\t\t\tconst shouldReact = this._changeTracker ? this._changeTracker.handleChange({\n\t\t\t\t\tchangedObservable: observable,\n\t\t\t\t\tchange,\n\t\t\t\t\tdidChange: (o): this is any => o === observable as any,\n\t\t\t\t}, this._changeSummary!) : true;\n\t\t\t\tif (shouldReact) {\n\t\t\t\t\tthis._state = AutorunState.stale;\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tonBugIndicatingError(e);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _isDependency(observable: IObservableWithChange<any, any>): boolean {\n\t\treturn this._dependencies.has(observable) && !this._dependenciesToBeRemoved.has(observable);\n\t}\n\n\t// IReader implementation\n\n\tprivate _ensureNoRunning(): void {\n\t\tif (!this._isRunning) { throw new BugIndicatingError('The reader object cannot be used outside its compute function!'); }\n\t}\n\n\tpublic readObservable<T>(observable: IObservable<T>): T {\n\t\tthis._ensureNoRunning();\n\n\t\t// In case the run action disposes the autorun\n\t\tif (this._disposed) {\n\t\t\treturn observable.get(); // warning: external call!\n\t\t}\n\n\t\tobservable.addObserver(this); // warning: external call!\n\t\tconst value = observable.get(); // warning: external call!\n\t\tthis._dependencies.add(observable);\n\t\tthis._dependenciesToBeRemoved.delete(observable);\n\t\treturn value;\n\t}\n\n\tprivate _store: DisposableStore | undefined = undefined;\n\tget store(): DisposableStore {\n\t\tthis._ensureNoRunning();\n\t\tif (this._disposed) {\n\t\t\tthrow new BugIndicatingError('Cannot access store after dispose');\n\t\t}\n\n\t\tif (this._store === undefined) {\n\t\t\tthis._store = new DisposableStore();\n\t\t}\n\t\treturn this._store;\n\t}\n\n\tprivate _delayedStore: DisposableStore | undefined = undefined;\n\n\tpublic debugGetState() {\n\t\treturn {\n\t\t\tisRunning: this._isRunning,\n\t\t\tupdateCount: this._updateCount,\n\t\t\tdependencies: this._dependencies,\n\t\t\tstate: this._state,\n\t\t\tstateStr: autorunStateToString(this._state),\n\t\t};\n\t}\n\n\tpublic debugRerun(): void {\n\t\tif (!this._isRunning) {\n\t\t\tthis._run();\n\t\t} else {\n\t\t\tthis._state = AutorunState.stale;\n\t\t}\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IObservable, IObservableWithChange, IObserver, IReaderWithStore } from '../base.js';\nimport { DebugNameData } from '../debugName.js';\nimport { assertFn, BugIndicatingError, DisposableStore, IDisposable, markAsDisposed, onBugIndicatingError, trackDisposable } from '../commonFacade/deps.js';\nimport { getLogger } from '../logging/logging.js';\nimport { IChangeTracker } from '../changeTracker.js';\nimport { DebugLocation } from '../debugLocation.js';\n\nexport const enum AutorunState {\n\t/**\n\t * A dependency could have changed.\n\t * We need to explicitly ask them if at least one dependency changed.\n\t */\n\tdependenciesMightHaveChanged = 1,\n\n\t/**\n\t * A dependency changed and we need to recompute.\n\t */\n\tstale = 2,\n\tupToDate = 3,\n}\n\nfunction autorunStateToString(state: AutorunState): string {\n\tswitch (state) {\n\t\tcase AutorunState.dependenciesMightHaveChanged: return 'dependenciesMightHaveChanged';\n\t\tcase AutorunState.stale: return 'stale';\n\t\tcase AutorunState.upToDate: return 'upToDate';\n\t\tdefault: return '<unknown>';\n\t}\n}\n\nexport class AutorunObserver<TChangeSummary = any> implements IObserver, IReaderWithStore, IDisposable {\n\tprivate _state = AutorunState.stale;\n\tprivate _updateCount = 0;\n\tprivate _disposed = false;\n\tprivate _dependencies = new Set<IObservable<any>>();\n\tprivate _dependenciesToBeRemoved = new Set<IObservable<any>>();\n\tprivate _changeSummary: TChangeSummary | undefined;\n\tprivate _isRunning = false;\n\n\tpublic get debugName(): string {\n\t\treturn this._debugNameData.getDebugName(this) ?? '(anonymous)';\n\t}\n\n\tconstructor(\n\t\tpublic readonly _debugNameData: DebugNameData,\n\t\tpublic readonly _runFn: (reader: IReaderWithStore, changeSummary: TChangeSummary) => void,\n\t\tprivate readonly _changeTracker: IChangeTracker<TChangeSummary> | undefined,\n\t\tdebugLocation: DebugLocation\n\t) {\n\t\tthis._changeSummary = this._changeTracker?.createChangeSummary(undefined);\n\t\tgetLogger()?.handleAutorunCreated(this, debugLocation);\n\t\tthis._run();\n\n\t\ttrackDisposable(this);\n\t}\n\n\tpublic dispose(): void {\n\t\tif (this._disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis._disposed = true;\n\t\tfor (const o of this._dependencies) {\n\t\t\to.removeObserver(this); // Warning: external call!\n\t\t}\n\t\tthis._dependencies.clear();\n\n\t\tif (this._store !== undefined) {\n\t\t\tthis._store.dispose();\n\t\t}\n\t\tif (this._delayedStore !== undefined) {\n\t\t\tthis._delayedStore.dispose();\n\t\t}\n\n\t\tgetLogger()?.handleAutorunDisposed(this);\n\t\tmarkAsDisposed(this);\n\t}\n\n\tprivate _run() {\n\t\tconst emptySet = this._dependenciesToBeRemoved;\n\t\tthis._dependenciesToBeRemoved = this._dependencies;\n\t\tthis._dependencies = emptySet;\n\n\t\tthis._state = AutorunState.upToDate;\n\n\t\ttry {\n\t\t\tif (!this._disposed) {\n\t\t\t\tgetLogger()?.handleAutorunStarted(this);\n\t\t\t\tconst changeSummary = this._changeSummary!;\n\t\t\t\tconst delayedStore = this._delayedStore;\n\t\t\t\tif (delayedStore !== undefined) {\n\t\t\t\t\tthis._delayedStore = undefined;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tthis._isRunning = true;\n\t\t\t\t\tif (this._changeTracker) {\n\t\t\t\t\t\tthis._changeTracker.beforeUpdate?.(this, changeSummary);\n\t\t\t\t\t\tthis._changeSummary = this._changeTracker.createChangeSummary(changeSummary); // Warning: external call!\n\t\t\t\t\t}\n\t\t\t\t\tif (this._store !== undefined) {\n\t\t\t\t\t\tthis._store.dispose();\n\t\t\t\t\t\tthis._store = undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runFn(this, changeSummary); // Warning: external call!\n\t\t\t\t} catch (e) {\n\t\t\t\t\tonBugIndicatingError(e);\n\t\t\t\t} finally {\n\t\t\t\t\tthis._isRunning = false;\n\t\t\t\t\tif (delayedStore !== undefined) {\n\t\t\t\t\t\tdelayedStore.dispose();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tif (!this._disposed) {\n\t\t\t\tgetLogger()?.handleAutorunFinished(this);\n\t\t\t}\n\t\t\t// We don't want our observed observables to think that they are (not even temporarily) not being observed.\n\t\t\t// Thus, we only unsubscribe from observables that are definitely not read anymore.\n\t\t\tfor (const o of this._dependenciesToBeRemoved) {\n\t\t\t\to.removeObserver(this); // Warning: external call!\n\t\t\t}\n\t\t\tthis._dependenciesToBeRemoved.clear();\n\t\t}\n\t}\n\n\tpublic toString(): string {\n\t\treturn `Autorun<${this.debugName}>`;\n\t}\n\n\t// IObserver implementation\n\tpublic beginUpdate(_observable: IObservable<any>): void {\n\t\tif (this._state === AutorunState.upToDate) {\n\t\t\tthis._state = AutorunState.dependenciesMightHaveChanged;\n\t\t}\n\t\tthis._updateCount++;\n\t}\n\n\tpublic endUpdate(_observable: IObservable<any>): void {\n\t\ttry {\n\t\t\tif (this._updateCount === 1) {\n\t\t\t\tdo {\n\t\t\t\t\tif (this._state === AutorunState.dependenciesMightHaveChanged) {\n\t\t\t\t\t\tthis._state = AutorunState.upToDate;\n\t\t\t\t\t\tfor (const d of this._dependencies) {\n\t\t\t\t\t\t\td.reportChanges(); // Warning: external call!\n\t\t\t\t\t\t\tif (this._state as AutorunState === AutorunState.stale) {\n\t\t\t\t\t\t\t\t// The other dependencies will refresh on demand\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._state !== AutorunState.upToDate) {\n\t\t\t\t\t\tthis._run(); // Warning: indirect external call!\n\t\t\t\t\t}\n\t\t\t\t} while (this._state !== AutorunState.upToDate);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis._updateCount--;\n\t\t}\n\n\t\tassertFn(() => this._updateCount >= 0);\n\t}\n\n\tpublic handlePossibleChange(observable: IObservable<any>): void {\n\t\tif (this._state === AutorunState.upToDate && this._isDependency(observable)) {\n\t\t\tthis._state = AutorunState.dependenciesMightHaveChanged;\n\t\t}\n\t}\n\n\tpublic handleChange<T, TChange>(observable: IObservableWithChange<T, TChange>, change: TChange): void {\n\t\tif (this._isDependency(observable)) {\n\t\t\tgetLogger()?.handleAutorunDependencyChanged(this, observable, change);\n\t\t\ttry {\n\t\t\t\t// Warning: external call!\n\t\t\t\tconst shouldReact = this._changeTracker ? this._changeTracker.handleChange({\n\t\t\t\t\tchangedObservable: observable,\n\t\t\t\t\tchange,\n\t\t\t\t\tdidChange: (o): this is any => o === observable as any,\n\t\t\t\t}, this._changeSummary!) : true;\n\t\t\t\tif (shouldReact) {\n\t\t\t\t\tthis._state = AutorunState.stale;\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tonBugIndicatingError(e);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _isDependency(observable: IObservableWithChange<any, any>): boolean {\n\t\treturn this._dependencies.has(observable) && !this._dependenciesToBeRemoved.has(observable);\n\t}\n\n\t// IReader implementation\n\n\tprivate _ensureNoRunning(): void {\n\t\tif (!this._isRunning) { throw new BugIndicatingError('The reader object cannot be used outside its compute function!'); }\n\t}\n\n\tpublic readObservable<T>(observable: IObservable<T>): T {\n\t\tthis._ensureNoRunning();\n\n\t\t// In case the run action disposes the autorun\n\t\tif (this._disposed) {\n\t\t\treturn observable.get(); // warning: external call!\n\t\t}\n\n\t\tobservable.addObserver(this); // warning: external call!\n\t\tconst value = observable.get(); // warning: external call!\n\t\tthis._dependencies.add(observable);\n\t\tthis._dependenciesToBeRemoved.delete(observable);\n\t\treturn value;\n\t}\n\n\tprivate _store: DisposableStore | undefined = undefined;\n\tget store(): DisposableStore {\n\t\tthis._ensureNoRunning();\n\t\tif (this._disposed) {\n\t\t\tthrow new BugIndicatingError('Cannot access store after dispose');\n\t\t}\n\n\t\tif (this._store === undefined) {\n\t\t\tthis._store = new DisposableStore();\n\t\t}\n\t\treturn this._store;\n\t}\n\n\tprivate _delayedStore: DisposableStore | undefined = undefined;\n\n\tpublic debugGetState() {\n\t\treturn {\n\t\t\tisRunning: this._isRunning,\n\t\t\tupdateCount: this._updateCount,\n\t\t\tdependencies: this._dependencies,\n\t\t\tstate: this._state,\n\t\t\tstateStr: autorunStateToString(this._state),\n\t\t};\n\t}\n\n\tpublic debugRerun(): void {\n\t\tif (!this._isRunning) {\n\t\t\tthis._run();\n\t\t} else {\n\t\t\tthis._state = AutorunState.stale;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -151,11 +151,22 @@ export class RevertHunkOrSelection extends Action2 {
|
|
|
151
151
|
super({
|
|
152
152
|
id: 'diffEditor.revert',
|
|
153
153
|
title: localize2(90, 'Revert'),
|
|
154
|
-
f1:
|
|
154
|
+
f1: true,
|
|
155
155
|
category: diffEditorCategory,
|
|
156
|
+
precondition: ContextKeyExpr.has('isInDiffEditor'),
|
|
156
157
|
});
|
|
157
158
|
}
|
|
158
159
|
run(accessor, arg) {
|
|
160
|
+
return arg ? this.runViaToolbarContext(accessor, arg) : this.runViaCursorOrSelection(accessor);
|
|
161
|
+
}
|
|
162
|
+
runViaCursorOrSelection(accessor) {
|
|
163
|
+
const diffEditor = findFocusedDiffEditor(accessor);
|
|
164
|
+
if (diffEditor instanceof DiffEditorWidget) {
|
|
165
|
+
diffEditor.revertFocusedRangeMappings();
|
|
166
|
+
}
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
runViaToolbarContext(accessor, arg) {
|
|
159
170
|
const diffEditor = findDiffEditor(accessor, arg.originalUri, arg.modifiedUri);
|
|
160
171
|
if (diffEditor instanceof DiffEditorWidget) {
|
|
161
172
|
diffEditor.revertRangeMappings(arg.mapping.innerChanges ?? []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["vs/editor/browser/widget/diffEditor/commands.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC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SAAS,GAAG,CAAC,CAAC,mBAAmB,EAAE,CAAC;YAC1C,IAAI,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;gBACvC,OAAO,CAAC,CAAC;YACV,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC","file":"commands.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { getActiveElement } from '../../../../base/browser/dom.js';\nimport { Codicon } from '../../../../base/common/codicons.js';\nimport { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';\nimport { ICodeEditor, IDiffEditor } from '../../editorBrowser.js';\nimport { EditorAction2, ServicesAccessor } from '../../editorExtensions.js';\nimport { ICodeEditorService } from '../../services/codeEditorService.js';\nimport { DiffEditorWidget } from './diffEditorWidget.js';\nimport { EditorContextKeys } from '../../../common/editorContextKeys.js';\nimport { localize2 } from '../../../../nls.js';\nimport { ILocalizedString } from '../../../../platform/action/common/action.js';\nimport { Action2, MenuId } from '../../../../platform/actions/common/actions.js';\nimport { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';\nimport { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';\nimport { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';\nimport './registrations.contribution.js';\nimport { DiffEditorSelectionHunkToolbarContext } from './features/gutterFeature.js';\nimport { URI } from '../../../../base/common/uri.js';\n\nexport class ToggleCollapseUnchangedRegions extends Action2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.toggleCollapseUnchangedRegions',\n\t\t\ttitle: localize2('toggleCollapseUnchangedRegions', 'Toggle Collapse Unchanged Regions'),\n\t\t\ticon: Codicon.map,\n\t\t\ttoggled: ContextKeyExpr.has('config.diffEditor.hideUnchangedRegions.enabled'),\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tmenu: {\n\t\t\t\twhen: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\t\tid: MenuId.EditorTitle,\n\t\t\t\torder: 22,\n\t\t\t\tgroup: 'navigation',\n\t\t\t},\n\t\t});\n\t}\n\n\trun(accessor: ServicesAccessor, ...args: unknown[]): void {\n\t\tconst configurationService = accessor.get(IConfigurationService);\n\t\tconst newValue = !configurationService.getValue<boolean>('diffEditor.hideUnchangedRegions.enabled');\n\t\tconfigurationService.updateValue('diffEditor.hideUnchangedRegions.enabled', newValue);\n\t}\n}\n\nexport class ToggleShowMovedCodeBlocks extends Action2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.toggleShowMovedCodeBlocks',\n\t\t\ttitle: localize2('toggleShowMovedCodeBlocks', 'Toggle Show Moved Code Blocks'),\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t});\n\t}\n\n\trun(accessor: ServicesAccessor, ...args: unknown[]): void {\n\t\tconst configurationService = accessor.get(IConfigurationService);\n\t\tconst newValue = !configurationService.getValue<boolean>('diffEditor.experimental.showMoves');\n\t\tconfigurationService.updateValue('diffEditor.experimental.showMoves', newValue);\n\t}\n}\n\nexport class ToggleUseInlineViewWhenSpaceIsLimited extends Action2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.toggleUseInlineViewWhenSpaceIsLimited',\n\t\t\ttitle: localize2('toggleUseInlineViewWhenSpaceIsLimited', 'Toggle Use Inline View When Space Is Limited'),\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t});\n\t}\n\n\trun(accessor: ServicesAccessor, ...args: unknown[]): void {\n\t\tconst configurationService = accessor.get(IConfigurationService);\n\t\tconst newValue = !configurationService.getValue<boolean>('diffEditor.useInlineViewWhenSpaceIsLimited');\n\t\tconfigurationService.updateValue('diffEditor.useInlineViewWhenSpaceIsLimited', newValue);\n\t}\n}\n\nconst diffEditorCategory: ILocalizedString = localize2('diffEditor', \"Diff Editor\");\n\nexport class SwitchSide extends EditorAction2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.switchSide',\n\t\t\ttitle: localize2('switchSide', 'Switch Side'),\n\t\t\ticon: Codicon.arrowSwap,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tf1: true,\n\t\t\tcategory: diffEditorCategory,\n\t\t});\n\t}\n\n\trunEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, arg?: { dryRun: boolean }): unknown {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tif (arg && arg.dryRun) {\n\t\t\t\treturn { destinationSelection: diffEditor.mapToOtherSide().destinationSelection };\n\t\t\t} else {\n\t\t\t\tdiffEditor.switchSide();\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\nexport class ExitCompareMove extends EditorAction2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.exitCompareMove',\n\t\t\ttitle: localize2('exitCompareMove', 'Exit Compare Move'),\n\t\t\ticon: Codicon.close,\n\t\t\tprecondition: EditorContextKeys.comparingMovedCode,\n\t\t\tf1: false,\n\t\t\tcategory: diffEditorCategory,\n\t\t\tkeybinding: {\n\t\t\t\tweight: 10000,\n\t\t\t\tprimary: KeyCode.Escape,\n\t\t\t}\n\t\t});\n\t}\n\n\trunEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, ...args: unknown[]): void {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tdiffEditor.exitCompareMove();\n\t\t}\n\t}\n}\n\nexport class CollapseAllUnchangedRegions extends EditorAction2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.collapseAllUnchangedRegions',\n\t\t\ttitle: localize2('collapseAllUnchangedRegions', 'Collapse All Unchanged Regions'),\n\t\t\ticon: Codicon.fold,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tf1: true,\n\t\t\tcategory: diffEditorCategory,\n\t\t});\n\t}\n\n\trunEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, ...args: unknown[]): void {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tdiffEditor.collapseAllUnchangedRegions();\n\t\t}\n\t}\n}\n\nexport class ShowAllUnchangedRegions extends EditorAction2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.showAllUnchangedRegions',\n\t\t\ttitle: localize2('showAllUnchangedRegions', 'Show All Unchanged Regions'),\n\t\t\ticon: Codicon.unfold,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tf1: true,\n\t\t\tcategory: diffEditorCategory,\n\t\t});\n\t}\n\n\trunEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, ...args: unknown[]): void {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tdiffEditor.showAllUnchangedRegions();\n\t\t}\n\t}\n}\n\nexport class RevertHunkOrSelection extends Action2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.revert',\n\t\t\ttitle: localize2('revert', 'Revert'),\n\t\t\tf1: false,\n\t\t\tcategory: diffEditorCategory,\n\t\t});\n\t}\n\n\trun(accessor: ServicesAccessor, arg: DiffEditorSelectionHunkToolbarContext): unknown {\n\t\tconst diffEditor = findDiffEditor(accessor, arg.originalUri, arg.modifiedUri);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tdiffEditor.revertRangeMappings(arg.mapping.innerChanges ?? []);\n\t\t}\n\t\treturn undefined;\n\t}\n}\n\nconst accessibleDiffViewerCategory: ILocalizedString = localize2('accessibleDiffViewer', \"Accessible Diff Viewer\");\n\nexport class AccessibleDiffViewerNext extends Action2 {\n\tpublic static id = 'editor.action.accessibleDiffViewer.next';\n\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: AccessibleDiffViewerNext.id,\n\t\t\ttitle: localize2('editor.action.accessibleDiffViewer.next', 'Go to Next Difference'),\n\t\t\tcategory: accessibleDiffViewerCategory,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tkeybinding: {\n\t\t\t\tprimary: KeyCode.F7,\n\t\t\t\tweight: KeybindingWeight.EditorContrib\n\t\t\t},\n\t\t\tf1: true,\n\t\t});\n\t}\n\n\tpublic override run(accessor: ServicesAccessor): void {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tdiffEditor?.accessibleDiffViewerNext();\n\t}\n}\n\nexport class AccessibleDiffViewerPrev extends Action2 {\n\tpublic static id = 'editor.action.accessibleDiffViewer.prev';\n\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: AccessibleDiffViewerPrev.id,\n\t\t\ttitle: localize2('editor.action.accessibleDiffViewer.prev', 'Go to Previous Difference'),\n\t\t\tcategory: accessibleDiffViewerCategory,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tkeybinding: {\n\t\t\t\tprimary: KeyMod.Shift | KeyCode.F7,\n\t\t\t\tweight: KeybindingWeight.EditorContrib\n\t\t\t},\n\t\t\tf1: true,\n\t\t});\n\t}\n\n\tpublic override run(accessor: ServicesAccessor): void {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tdiffEditor?.accessibleDiffViewerPrev();\n\t}\n}\n\nexport function findDiffEditor(accessor: ServicesAccessor, originalUri: URI, modifiedUri: URI): IDiffEditor | null {\n\tconst codeEditorService = accessor.get(ICodeEditorService);\n\tconst diffEditors = codeEditorService.listDiffEditors();\n\n\treturn diffEditors.find(diffEditor => {\n\t\tconst modified = diffEditor.getModifiedEditor();\n\t\tconst original = diffEditor.getOriginalEditor();\n\n\t\treturn modified && modified.getModel()?.uri.toString() === modifiedUri.toString()\n\t\t\t&& original && original.getModel()?.uri.toString() === originalUri.toString();\n\t}) || null;\n}\n\nexport function findFocusedDiffEditor(accessor: ServicesAccessor): IDiffEditor | null {\n\tconst codeEditorService = accessor.get(ICodeEditorService);\n\tconst diffEditors = codeEditorService.listDiffEditors();\n\n\tconst activeElement = getActiveElement();\n\tif (activeElement) {\n\t\tfor (const d of diffEditors) {\n\t\t\tconst container = d.getContainerDomNode();\n\t\t\tif (container.contains(activeElement)) {\n\t\t\t\treturn d;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["vs/editor/browser/widget/diffEditor/commands.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAoB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4DAA4D,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAC;AAEtF,OAAO,iCAAiC,CAAC;AAIzC,MAAM,OAAO,8BAA+B,SAAQ,OAAO;IAC1D;QACC,KAAK,CAAC;YACL,EAAE,EAAE,2CAA2C;YAC/C,KAAK,EAAE,SAAS,CAAC,EAAgC,EAAE,mCAAmC,CAAC;YACvF,IAAI,EAAE,OAAO,CAAC,GAAG;YACjB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AO,IAAI,CAAC;AACb,CAAC","file":"commands.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { getActiveElement } from '../../../../base/browser/dom.js';\nimport { Codicon } from '../../../../base/common/codicons.js';\nimport { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';\nimport { ICodeEditor, IDiffEditor } from '../../editorBrowser.js';\nimport { EditorAction2, ServicesAccessor } from '../../editorExtensions.js';\nimport { ICodeEditorService } from '../../services/codeEditorService.js';\nimport { DiffEditorWidget } from './diffEditorWidget.js';\nimport { EditorContextKeys } from '../../../common/editorContextKeys.js';\nimport { localize2 } from '../../../../nls.js';\nimport { ILocalizedString } from '../../../../platform/action/common/action.js';\nimport { Action2, MenuId } from '../../../../platform/actions/common/actions.js';\nimport { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';\nimport { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';\nimport { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';\nimport './registrations.contribution.js';\nimport { DiffEditorSelectionHunkToolbarContext } from './features/gutterFeature.js';\nimport { URI } from '../../../../base/common/uri.js';\n\nexport class ToggleCollapseUnchangedRegions extends Action2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.toggleCollapseUnchangedRegions',\n\t\t\ttitle: localize2('toggleCollapseUnchangedRegions', 'Toggle Collapse Unchanged Regions'),\n\t\t\ticon: Codicon.map,\n\t\t\ttoggled: ContextKeyExpr.has('config.diffEditor.hideUnchangedRegions.enabled'),\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tmenu: {\n\t\t\t\twhen: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\t\tid: MenuId.EditorTitle,\n\t\t\t\torder: 22,\n\t\t\t\tgroup: 'navigation',\n\t\t\t},\n\t\t});\n\t}\n\n\trun(accessor: ServicesAccessor, ...args: unknown[]): void {\n\t\tconst configurationService = accessor.get(IConfigurationService);\n\t\tconst newValue = !configurationService.getValue<boolean>('diffEditor.hideUnchangedRegions.enabled');\n\t\tconfigurationService.updateValue('diffEditor.hideUnchangedRegions.enabled', newValue);\n\t}\n}\n\nexport class ToggleShowMovedCodeBlocks extends Action2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.toggleShowMovedCodeBlocks',\n\t\t\ttitle: localize2('toggleShowMovedCodeBlocks', 'Toggle Show Moved Code Blocks'),\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t});\n\t}\n\n\trun(accessor: ServicesAccessor, ...args: unknown[]): void {\n\t\tconst configurationService = accessor.get(IConfigurationService);\n\t\tconst newValue = !configurationService.getValue<boolean>('diffEditor.experimental.showMoves');\n\t\tconfigurationService.updateValue('diffEditor.experimental.showMoves', newValue);\n\t}\n}\n\nexport class ToggleUseInlineViewWhenSpaceIsLimited extends Action2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.toggleUseInlineViewWhenSpaceIsLimited',\n\t\t\ttitle: localize2('toggleUseInlineViewWhenSpaceIsLimited', 'Toggle Use Inline View When Space Is Limited'),\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t});\n\t}\n\n\trun(accessor: ServicesAccessor, ...args: unknown[]): void {\n\t\tconst configurationService = accessor.get(IConfigurationService);\n\t\tconst newValue = !configurationService.getValue<boolean>('diffEditor.useInlineViewWhenSpaceIsLimited');\n\t\tconfigurationService.updateValue('diffEditor.useInlineViewWhenSpaceIsLimited', newValue);\n\t}\n}\n\nconst diffEditorCategory: ILocalizedString = localize2('diffEditor', \"Diff Editor\");\n\nexport class SwitchSide extends EditorAction2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.switchSide',\n\t\t\ttitle: localize2('switchSide', 'Switch Side'),\n\t\t\ticon: Codicon.arrowSwap,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tf1: true,\n\t\t\tcategory: diffEditorCategory,\n\t\t});\n\t}\n\n\trunEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, arg?: { dryRun: boolean }): unknown {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tif (arg && arg.dryRun) {\n\t\t\t\treturn { destinationSelection: diffEditor.mapToOtherSide().destinationSelection };\n\t\t\t} else {\n\t\t\t\tdiffEditor.switchSide();\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\nexport class ExitCompareMove extends EditorAction2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.exitCompareMove',\n\t\t\ttitle: localize2('exitCompareMove', 'Exit Compare Move'),\n\t\t\ticon: Codicon.close,\n\t\t\tprecondition: EditorContextKeys.comparingMovedCode,\n\t\t\tf1: false,\n\t\t\tcategory: diffEditorCategory,\n\t\t\tkeybinding: {\n\t\t\t\tweight: 10000,\n\t\t\t\tprimary: KeyCode.Escape,\n\t\t\t}\n\t\t});\n\t}\n\n\trunEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, ...args: unknown[]): void {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tdiffEditor.exitCompareMove();\n\t\t}\n\t}\n}\n\nexport class CollapseAllUnchangedRegions extends EditorAction2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.collapseAllUnchangedRegions',\n\t\t\ttitle: localize2('collapseAllUnchangedRegions', 'Collapse All Unchanged Regions'),\n\t\t\ticon: Codicon.fold,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tf1: true,\n\t\t\tcategory: diffEditorCategory,\n\t\t});\n\t}\n\n\trunEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, ...args: unknown[]): void {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tdiffEditor.collapseAllUnchangedRegions();\n\t\t}\n\t}\n}\n\nexport class ShowAllUnchangedRegions extends EditorAction2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.showAllUnchangedRegions',\n\t\t\ttitle: localize2('showAllUnchangedRegions', 'Show All Unchanged Regions'),\n\t\t\ticon: Codicon.unfold,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tf1: true,\n\t\t\tcategory: diffEditorCategory,\n\t\t});\n\t}\n\n\trunEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, ...args: unknown[]): void {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tdiffEditor.showAllUnchangedRegions();\n\t\t}\n\t}\n}\n\nexport class RevertHunkOrSelection extends Action2 {\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: 'diffEditor.revert',\n\t\t\ttitle: localize2('revert', 'Revert'),\n\t\t\tf1: true,\n\t\t\tcategory: diffEditorCategory,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t});\n\t}\n\n\trun(accessor: ServicesAccessor, arg?: DiffEditorSelectionHunkToolbarContext): unknown {\n\t\treturn arg ? this.runViaToolbarContext(accessor, arg) : this.runViaCursorOrSelection(accessor);\n\t}\n\n\trunViaCursorOrSelection(accessor: ServicesAccessor): unknown {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tdiffEditor.revertFocusedRangeMappings();\n\t\t}\n\t\treturn undefined;\n\t}\n\n\trunViaToolbarContext(accessor: ServicesAccessor, arg: DiffEditorSelectionHunkToolbarContext): unknown {\n\t\tconst diffEditor = findDiffEditor(accessor, arg.originalUri, arg.modifiedUri);\n\t\tif (diffEditor instanceof DiffEditorWidget) {\n\t\t\tdiffEditor.revertRangeMappings(arg.mapping.innerChanges ?? []);\n\t\t}\n\t\treturn undefined;\n\t}\n}\n\nconst accessibleDiffViewerCategory: ILocalizedString = localize2('accessibleDiffViewer', \"Accessible Diff Viewer\");\n\nexport class AccessibleDiffViewerNext extends Action2 {\n\tpublic static id = 'editor.action.accessibleDiffViewer.next';\n\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: AccessibleDiffViewerNext.id,\n\t\t\ttitle: localize2('editor.action.accessibleDiffViewer.next', 'Go to Next Difference'),\n\t\t\tcategory: accessibleDiffViewerCategory,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tkeybinding: {\n\t\t\t\tprimary: KeyCode.F7,\n\t\t\t\tweight: KeybindingWeight.EditorContrib\n\t\t\t},\n\t\t\tf1: true,\n\t\t});\n\t}\n\n\tpublic override run(accessor: ServicesAccessor): void {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tdiffEditor?.accessibleDiffViewerNext();\n\t}\n}\n\nexport class AccessibleDiffViewerPrev extends Action2 {\n\tpublic static id = 'editor.action.accessibleDiffViewer.prev';\n\n\tconstructor() {\n\t\tsuper({\n\t\t\tid: AccessibleDiffViewerPrev.id,\n\t\t\ttitle: localize2('editor.action.accessibleDiffViewer.prev', 'Go to Previous Difference'),\n\t\t\tcategory: accessibleDiffViewerCategory,\n\t\t\tprecondition: ContextKeyExpr.has('isInDiffEditor'),\n\t\t\tkeybinding: {\n\t\t\t\tprimary: KeyMod.Shift | KeyCode.F7,\n\t\t\t\tweight: KeybindingWeight.EditorContrib\n\t\t\t},\n\t\t\tf1: true,\n\t\t});\n\t}\n\n\tpublic override run(accessor: ServicesAccessor): void {\n\t\tconst diffEditor = findFocusedDiffEditor(accessor);\n\t\tdiffEditor?.accessibleDiffViewerPrev();\n\t}\n}\n\nexport function findDiffEditor(accessor: ServicesAccessor, originalUri: URI, modifiedUri: URI): IDiffEditor | null {\n\tconst codeEditorService = accessor.get(ICodeEditorService);\n\tconst diffEditors = codeEditorService.listDiffEditors();\n\n\treturn diffEditors.find(diffEditor => {\n\t\tconst modified = diffEditor.getModifiedEditor();\n\t\tconst original = diffEditor.getOriginalEditor();\n\n\t\treturn modified && modified.getModel()?.uri.toString() === modifiedUri.toString()\n\t\t\t&& original && original.getModel()?.uri.toString() === originalUri.toString();\n\t}) || null;\n}\n\nexport function findFocusedDiffEditor(accessor: ServicesAccessor): IDiffEditor | null {\n\tconst codeEditorService = accessor.get(ICodeEditorService);\n\tconst diffEditors = codeEditorService.listDiffEditors();\n\n\tconst activeElement = getActiveElement();\n\tif (activeElement) {\n\t\tfor (const d of diffEditors) {\n\t\t\tconst container = d.getContainerDomNode();\n\t\t\tif (container.contains(activeElement)) {\n\t\t\t\treturn d;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n"]}
|
|
@@ -24,6 +24,7 @@ import { IInstantiationService } from '../../../../platform/instantiation/common
|
|
|
24
24
|
import { ServiceCollection } from '../../../../platform/instantiation/common/serviceCollection.js';
|
|
25
25
|
import { bindContextKey } from '../../../../platform/observable/common/platformObservableUtils.js';
|
|
26
26
|
import { IEditorProgressService } from '../../../../platform/progress/common/progress.js';
|
|
27
|
+
import { LineRange } from '../../../common/core/ranges/lineRange.js';
|
|
27
28
|
import { Position } from '../../../common/core/position.js';
|
|
28
29
|
import { Range } from '../../../common/core/range.js';
|
|
29
30
|
import { EditorType } from '../../../common/editorCommon.js';
|
|
@@ -358,6 +359,30 @@ let DiffEditorWidget = class DiffEditorWidget extends DelegatingEditor {
|
|
|
358
359
|
}));
|
|
359
360
|
this._editors.modified.executeEdits('diffEditor', changes);
|
|
360
361
|
}
|
|
362
|
+
revertFocusedRangeMappings() {
|
|
363
|
+
const model = this._diffModel.get();
|
|
364
|
+
if (!model || !model.isDiffUpToDate.get()) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const diffs = this._diffModel.get()?.diff.get()?.mappings;
|
|
368
|
+
if (!diffs || diffs.length === 0) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const modifiedEditor = this._editors.modified;
|
|
372
|
+
if (!modifiedEditor.hasTextFocus()) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
const curLineNumber = modifiedEditor.getPosition().lineNumber;
|
|
376
|
+
const selection = modifiedEditor.getSelection();
|
|
377
|
+
const selectedRange = LineRange.fromRange(selection || new Range(curLineNumber, 0, curLineNumber, 0));
|
|
378
|
+
const diffsToRevert = diffs.filter(d => {
|
|
379
|
+
return d.lineRangeMapping.modified.intersect(selectedRange);
|
|
380
|
+
});
|
|
381
|
+
modifiedEditor.executeEdits('diffEditor', diffsToRevert.map(d => ({
|
|
382
|
+
range: d.lineRangeMapping.modified.toExclusiveRange(),
|
|
383
|
+
text: model.model.original.getValueInRange(d.lineRangeMapping.original.toExclusiveRange())
|
|
384
|
+
})));
|
|
385
|
+
}
|
|
361
386
|
_goTo(diff) {
|
|
362
387
|
this._editors.modified.setPosition(new Position(diff.lineRangeMapping.modified.startLineNumber, 1));
|
|
363
388
|
this._editors.modified.revealRangeInCenter(diff.lineRangeMapping.modified.toExclusiveRange());
|