Skip to content

Commit

Permalink
Refactoring: Move the computation of the commentOffset into the cell …
Browse files Browse the repository at this point in the history
…layouting function.

microsoft#214332.

The cellComments should not have to know about outputs. The reason this is undesirable is that these exist only for code cells, not for markup cells - and I would like to make cellComments work for markup cells as well.
  • Loading branch information
rehmsen committed Jul 2, 2024
1 parent 9664fa5 commit a3d69a6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export interface CodeCellLayoutInfo {
readonly editorWidth: number;
readonly estimatedHasHorizontalScrolling: boolean;
readonly statusBarHeight: number;
readonly commentOffset: number;
readonly commentHeight: number;
readonly totalHeight: number;
readonly outputContainerOffset: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class CellComments extends CellContentPart {
if (!this._commentThreadWidget.value && info) {
await this._createCommentTheadWidget(info.owner, info.thread);
const layoutInfo = (this.currentElement as CodeCellViewModel).layoutInfo;
this.container.style.top = `${layoutInfo.outputContainerOffset + layoutInfo.outputTotalHeight}px`;
this.container.style.top = `${layoutInfo.commentOffset}px`;
this.currentElement.commentHeight = this._calculateCommentThreadHeight(this._commentThreadWidget.value!.getDimensions().height);
return;
}
Expand Down Expand Up @@ -170,7 +170,7 @@ export class CellComments extends CellContentPart {
override updateInternalLayoutNow(element: ICellViewModel): void {
if (this.currentElement?.cellKind === CellKind.Code && this._commentThreadWidget.value) {
const layoutInfo = (element as CodeCellViewModel).layoutInfo;
this.container.style.top = `${layoutInfo.outputContainerOffset + layoutInfo.outputTotalHeight}px`;
this.container.style.top = `${layoutInfo.commentOffset}px`;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
: 0,
chatHeight: 0,
statusBarHeight: 0,
commentOffset: 0,
commentHeight: 0,
outputContainerOffset: 0,
outputTotalHeight: 0,
Expand Down Expand Up @@ -289,11 +290,12 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
editorHeight,
editorWidth,
statusBarHeight,
commentHeight,
outputContainerOffset,
outputTotalHeight,
outputShowMoreContainerHeight,
outputShowMoreContainerOffset,
commentOffset: outputContainerOffset + outputTotalHeight,
commentHeight,
totalHeight,
codeIndicatorHeight,
outputIndicatorHeight,
Expand Down Expand Up @@ -330,11 +332,12 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
editorWidth,
chatHeight: chatHeight,
statusBarHeight: 0,
commentHeight,
outputContainerOffset,
outputTotalHeight,
outputShowMoreContainerHeight,
outputShowMoreContainerOffset,
commentOffset: outputContainerOffset + outputTotalHeight,
commentHeight,
totalHeight,
codeIndicatorHeight,
outputIndicatorHeight,
Expand Down

0 comments on commit a3d69a6

Please sign in to comment.