Skip to content

Commit

Permalink
Refactoring: Extract shared fields of CodeCellLayoutInfo and MarkupCe…
Browse files Browse the repository at this point in the history
…llLayoutInfo.

microsoft#214332.

Some layouting tasks, like soon layouting comments, should not have to deal with this distinction. I am extracting the fields that are already shared into an interface that other code can use without differentiating.

I am not yet actually moving their computation into a separate file, as that will require some small behavior changes.
  • Loading branch information
rehmsen authored and aaronchucarroll committed Jul 10, 2024
1 parent be6849f commit 4e1fb18
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,58 +175,55 @@ export enum CellLayoutState {
Measured
}

export interface CodeCellLayoutInfo {
/** LayoutInfo of the parts that are shared between all cell types. */
export interface CellLayoutInfo {
readonly layoutState: CellLayoutState;
readonly fontInfo: FontInfo | null;
readonly chatHeight: number;
readonly editorHeight: number;
readonly editorWidth: number;
readonly estimatedHasHorizontalScrolling: boolean;
readonly editorHeight: number;
readonly statusBarHeight: number;
readonly bottomToolbarOffset: number;
readonly totalHeight: number;
}

export interface CellLayoutChangeEvent {
readonly font?: FontInfo;
readonly outerWidth?: number;
}

export interface CodeCellLayoutInfo extends CellLayoutInfo {
readonly estimatedHasHorizontalScrolling: boolean;
readonly commentOffset: number;
readonly commentHeight: number;
readonly totalHeight: number;
readonly outputContainerOffset: number;
readonly outputTotalHeight: number;
readonly outputShowMoreContainerHeight: number;
readonly outputShowMoreContainerOffset: number;
readonly bottomToolbarOffset: number;
readonly layoutState: CellLayoutState;
readonly codeIndicatorHeight: number;
readonly outputIndicatorHeight: number;
}

export interface CodeCellLayoutChangeEvent {
export interface CodeCellLayoutChangeEvent extends CellLayoutChangeEvent {
readonly source?: string;
readonly chatHeight?: boolean;
readonly editorHeight?: boolean;
readonly commentHeight?: boolean;
readonly outputHeight?: boolean;
readonly outputShowMoreContainerHeight?: number;
readonly totalHeight?: boolean;
readonly outerWidth?: number;
readonly font?: FontInfo;
}

export interface MarkupCellLayoutInfo {
readonly fontInfo: FontInfo | null;
readonly chatHeight: number;
readonly editorWidth: number;
readonly editorHeight: number;
readonly statusBarHeight: number;
export interface MarkupCellLayoutInfo extends CellLayoutInfo {
readonly previewHeight: number;
readonly bottomToolbarOffset: number;
readonly totalHeight: number;
readonly layoutState: CellLayoutState;
readonly foldHintHeight: number;
}

export enum CellLayoutContext {
Fold
}

export interface MarkupCellLayoutChangeEvent {
readonly font?: FontInfo;
readonly outerWidth?: number;
export interface MarkupCellLayoutChangeEvent extends CellLayoutChangeEvent {
readonly editorHeight?: number;
readonly previewHeight?: number;
totalHeight?: number;
Expand All @@ -242,7 +239,7 @@ export interface ICellViewModel extends IGenericCellViewModel {
readonly model: NotebookCellTextModel;
readonly id: string;
readonly textBuffer: IReadonlyTextBuffer;
readonly layoutInfo: { totalHeight: number; bottomToolbarOffset: number; editorWidth: number; editorHeight: number; statusBarHeight: number; chatHeight: number };
readonly layoutInfo: CellLayoutInfo;
readonly onDidChangeLayout: Event<ICommonCellViewModelLayoutChangeInfo>;
readonly onDidChangeCellStatusBarItems: Event<void>;
readonly onCellDecorationsChanged: Event<{ added: INotebookCellDecorationOptions[]; removed: INotebookCellDecorationOptions[] }>;
Expand Down

0 comments on commit 4e1fb18

Please sign in to comment.