import { Dimension } from "../../../../base/browser/dom.js"; import { Disposable } from "../../../../base/common/lifecycle.js"; import { IObservable, ITransaction } from "../../../../base/common/observable.js"; import { URI } from "../../../../base/common/uri.js"; import { IContextKeyService } from "../../../../platform/contextkey/common/contextkey.service.js"; import { IInstantiationService } from "../../../../platform/instantiation/common/instantiation.js"; import { ILogService } from "../../../../platform/log/common/log.service.js"; import { IDiffEditorOptions } from "../../../common/config/editorOptions.js"; import { ISelection } from "../../../common/core/selection.js"; import { IDiffEditor } from "../../../common/editorCommon.js"; import { IMultiDiffResourceId } from "../../../common/multiDiffEditor.js"; import { ICodeEditor } from "../../editorBrowser.js"; import { IDocumentDiffItem } from "./model.js"; import { IMultiDiffEditorVariantConfiguration } from "./multiDiffEditorOptions.js"; import { DocumentDiffItemViewModel, MultiDiffEditorViewModel } from "./multiDiffEditorViewModel.js"; import { RevealOptions } from "./multiDiffEditorWidget.js"; import { IWorkbenchUIElementFactory } from "./workbenchUIElementFactory.js"; export declare class MultiDiffEditorWidgetImpl extends Disposable { private readonly _element; private readonly _dimension; private readonly _viewModel; private readonly _workbenchUIElementFactory; private readonly _variantConfiguration; private readonly _diffLayoutOptions; private readonly _diffEditorOptions; private readonly _paddingBottomPx; private readonly _parentContextKeyService; private readonly _parentInstantiationService; private readonly _scrollView; private readonly _elements; private readonly _optionsOverride; readonly scrollTop: IObservable; readonly scrollLeft: IObservable; readonly layoutDebugState: IObservable; /** Diff items whose content intersects the viewport, in document order. */ readonly visibleDiffItems: IObservable; private readonly _viewItemsInfo; private readonly _viewItems; private readonly _spaceBetweenPx; readonly activeControl: import("../../../../base/common/observable.js").IObservableWithChange; private readonly _contextKeyService; private readonly _instantiationService; private readonly _logger; /** * When `true`, the automatic "select the first change" initialization that * runs once the view model finishes loading does not move keyboard focus * into the editor. Driven by {@link setPreserveFocusOnLoad} so a * `preserveFocus` open (e.g. restored in the background or on a session * switch) does not steal focus, while a normal user-initiated open does. */ private _preserveFocusOnLoad; constructor(_element: HTMLElement, _dimension: IObservable, _viewModel: IObservable, _workbenchUIElementFactory: IWorkbenchUIElementFactory, _variantConfiguration: IMultiDiffEditorVariantConfiguration, _diffLayoutOptions: IObservable, _diffEditorOptions: IDiffEditorOptions | undefined, _paddingBottomPx: IObservable, _parentContextKeyService: IContextKeyService, _parentInstantiationService: IInstantiationService, logService: ILogService); setScrollState(scrollState: { top?: number; left?: number; }): void; /** * Retries a restored scroll offset as dimensions change until it lands. * Navigation away from the clamped offset with unchanged dimensions cancels restoration. */ private _applyPendingScrollState; /** * Clears any pending restoration state (documents, active item, scroll). Called * when a new model is installed without a view state, so it cannot inherit the * previous model's state for overlapping diff keys. */ clearPendingRestorationState(): void; /** * Controls whether the automatic first-change selection that runs once the * view model finishes loading preserves focus instead of moving it into the * editor. Set to `true` for `preserveFocus` opens so focus is not stolen * from elsewhere. */ setPreserveFocusOnLoad(preserveFocus: boolean): void; getRootElement(): HTMLElement; getContextKeyService(): IContextKeyService; getScopedInstantiationService(): IInstantiationService; resetWidthBasedLayout(): void; reveal(resource: IMultiDiffResourceId, options?: RevealOptions): void; getViewState(): IMultiDiffEditorViewState; /** This accounts for documents that are not loaded yet. */ private _lastDocStates; /** * The active diff item to restore once the documents are loaded. Restoring it * suppresses the automatic first-change navigation (which would expand the * first file and reset scroll), so the restored state wins. Consumed once. */ private _lastActiveDiffItemKey; /** A restored scroll offset waiting for the scrollable dimensions to be known. */ private _pendingScrollState; private _hasAppliedPendingScrollState; private _lastPendingScrollDimensions; setViewState(viewState: IMultiDiffEditorViewState, tx?: ITransaction): void; /** * Restores the persisted active diff item (if any) onto the view model, so the * automatic first-change navigation is skipped. On an explicit (non-preserve-focus) * open it also moves focus into the restored item's editor, mirroring the * first-change navigation it replaces. Returns whether it was applied. */ private _restorePendingActiveDiffItem; findDocumentDiffItem(resource: URI): IDocumentDiffItem | undefined; focus(): boolean; tryGetCodeEditor(resource: URI): { diffEditor: IDiffEditor; editor: ICodeEditor; } | undefined; goToNextChange(): void; goToPreviousChange(): void; private _navigateToChange; private _goToFile; } export interface IMultiDiffEditorViewState { scrollState: { top: number; left: number; }; docStates?: Record; /** Key ({@link DocumentDiffItemViewModel.getKey}) of the active diff item, if any. */ activeDiffItemKey?: string; } interface IMultiDiffDocState { collapsed: boolean; selections?: ISelection[]; } export interface IMultiDiffEditorLayoutDebugState { readonly scrollLeft: number; readonly scrollDimensions: { readonly width: number; readonly height: number; readonly scrollWidth: number; readonly scrollHeight: number; }; readonly layout: { readonly revision: number; readonly scrollTop: number; readonly logicalScrollHeight: number; readonly scrollHeight: number; readonly renderedHeight: number; readonly leadingScrollSlack: number; readonly trailingScrollSlack: number; readonly contentViewport: ISerializedOffsetRange; readonly renderedViewport: ISerializedOffsetRange; readonly hiddenContentHeightAboveViewport: number; }; readonly geometryEdit: { readonly fromRevision: number; readonly toRevision: number; readonly edits: readonly { readonly oldRange: ISerializedOffsetRange; readonly newRange: ISerializedOffsetRange; }[]; readonly anchorKind: "viewportTop" | "viewportBottom" | "logical" | "item"; readonly anchorOffset: number; readonly mappedAnchorOffset: number; readonly anchorViewportOffset: number; readonly desiredScrollTop: number; readonly appliedScrollTop: number; readonly leadingScrollSlack: number; readonly trailingScrollSlack: number; } | undefined; readonly items: readonly IMultiDiffEditorItemLayoutDebugState[]; } interface IMultiDiffEditorItemLayoutDebugState { readonly key: string; readonly label: string; readonly originalUri: string | null; readonly modifiedUri: string | null; readonly collapsed: boolean; readonly hasTemplate: boolean; readonly verticalState: { readonly contentHeight: number; readonly itemViewportOffset: number; }; readonly maxScroll: number; readonly layout: { readonly contentRange: ISerializedOffsetRange; readonly renderedRange: ISerializedOffsetRange; readonly maxScrollOffset: number; readonly scrollOffset: number; readonly visibility: "before" | "visible" | "after"; }; } interface ISerializedOffsetRange { readonly start: number; readonly endExclusive: number; } export {};