Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep cell run and toolbar below sticky -- fix #188690 #188975

Merged
merged 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
height: this._dimension!.height,
fontInfo: this._fontInfo!,
scrollHeight: this._list?.getScrollHeight() ?? 0,
stickyHeight: 0,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
private _notebookTopToolbarContainer!: HTMLElement;
private _notebookTopToolbar!: NotebookEditorWorkbenchToolbar;
private _notebookStickyScrollContainer!: HTMLElement;
private _notebookStickyScroll!: NotebookStickyScroll;
private _notebookOverviewRulerContainer!: HTMLElement;
private _notebookOverviewRuler!: NotebookOverviewRuler;
private _body!: HTMLElement;
Expand Down Expand Up @@ -1046,7 +1047,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
}

private _registerNotebookStickyScroll() {
this._register(this.instantiationService.createInstance(NotebookStickyScroll, this._notebookStickyScrollContainer, this, this._notebookOutline, this._list));
this._notebookStickyScroll = this._register(this.instantiationService.createInstance(NotebookStickyScroll, this._notebookStickyScrollContainer, this, this._notebookOutline, this._list));
}

private _updateOutputRenderers() {
Expand Down Expand Up @@ -2601,7 +2602,8 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
width: this._dimension?.width ?? 0,
height: this._dimension?.height ?? 0,
scrollHeight: this._list?.getScrollHeight() ?? 0,
fontInfo: this._fontInfo!
fontInfo: this._fontInfo!,
stickyHeight: this._notebookStickyScroll.getCurrentStickyHeight()
Yoyokrazy marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface NotebookLayoutInfo {
height: number;
scrollHeight: number;
fontInfo: FontInfo;
stickyHeight: number;
}

export interface CellViewModelStateChangeEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export function registerCellToolbarStickyScroll(notebookEditor: INotebookEditor,
if (cell.isInputCollapsed) {
element.style.top = '';
} else {
const stickyHeight = notebookEditor.getLayoutInfo().stickyHeight;
const scrollTop = notebookEditor.scrollTop;
const elementTop = notebookEditor.getAbsoluteTopOfElement(cell);
const diff = scrollTop - elementTop + extraOffset;
const diff = scrollTop - elementTop + extraOffset + stickyHeight;
const maxTop = cell.layoutInfo.editorHeight + cell.layoutInfo.statusBarHeight - 45; // subtract roughly the height of the execution order label plus padding
const top = maxTop > 20 ? // Don't move the run button if it can only move a very short distance
clamp(min, diff, maxTop) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export class NotebookStickyScroll extends Disposable {
return this.domNode;
}

getCurrentStickyHeight() {
return this.currentStickyLines.size * 22;
}

constructor(
private readonly domNode: HTMLElement,
private readonly notebookEditor: INotebookEditor,
Expand Down