import { Disposable } from "../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../base/common/observable.js"; import { URI } from "../../../../base/common/uri.js"; import { ILogService } from "../../../../platform/log/common/log.service.js"; import { MultiDiffEditorViewModel } from "./multiDiffEditorViewModel.js"; /** A diff item of the multi diff editor, as far as logging is concerned. */ export interface ILoggedDiffItem { getKey(): string; /** Short, log friendly name of the item. */ getLabel(): string; readonly collapsed: IObservable; readonly contentHeight: IObservable; } /** The widget state traced by {@link MultiDiffEditorLogger.logStateChanges}. */ export interface ILoggedEditorState { readonly viewModel: IObservable; readonly items: IObservable; readonly spaceBetweenPx: number; readonly getScrollTop: () => number; readonly isPreserveFocusOnLoad: () => boolean; } /** * Trace logger for the multi diff editor. Logs the state transitions that are * hard to observe from the outside (scroll offsets that are set programmatically, * content height changes, collapsed state changes and view state save/restore), * so bugs like "the editor jumped while scrolling" or "this file was expanded * even though it was collapsed" can be reconstructed from the log. * * Enable with `Developer: Set Log Level...` > `Window` > `Trace`. */ export declare class MultiDiffEditorLogger extends Disposable { private readonly _logService; /** Last logged collapsed state per diff item, to only log actual changes. */ private readonly _lastLoggedCollapsed; /** Last logged content height per diff item, to only log actual changes. */ private readonly _lastLoggedContentHeight; private readonly _isEnabled; constructor(_logService: ILogService); /** * Whether trace logging is on. Check this before computing data that is only * needed for logging. */ get isEnabled(): boolean; log(message: string, data?: Record): void; /** * Traces the state transitions that cannot be reconstructed after the fact: * view model/loading changes, collapsed state changes (no matter who caused * them) and content height changes, which are the usual cause of the view * jumping while scrolling. Per-frame rendering is deliberately not traced. * * The observers only exist while trace logging is on, so nothing is observed * (and no state is tracked) in the default case; they are recreated when the * log level is raised to trace again. */ logStateChanges(state: ILoggedEditorState): void; } /** Short, log friendly name of a diff item resource. */ export declare function formatUri(uri: URI | undefined): string; /** Turns a {@link DocumentDiffItemViewModel.getKey} value into a short log label. */ export declare function formatDiffItemKey(key: string | undefined): string;