Skip to content

Commit 4ce8fad

Browse files
authored
keep cell run and toolbar below sticky -- fix microsoft#188690 (microsoft#188975)
* fix microsoft#188690 -- keep cell run and toolbar below sticky * chain operator to avoid undefined issues * fallback value
1 parent 8451eb5 commit 4ce8fad

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
999999
height: this._dimension!.height,
10001000
fontInfo: this._fontInfo!,
10011001
scrollHeight: this._list?.getScrollHeight() ?? 0,
1002+
stickyHeight: 0,
10021003
};
10031004
}
10041005

src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
179179
private _notebookTopToolbarContainer!: HTMLElement;
180180
private _notebookTopToolbar!: NotebookEditorWorkbenchToolbar;
181181
private _notebookStickyScrollContainer!: HTMLElement;
182+
private _notebookStickyScroll!: NotebookStickyScroll;
182183
private _notebookOverviewRulerContainer!: HTMLElement;
183184
private _notebookOverviewRuler!: NotebookOverviewRuler;
184185
private _body!: HTMLElement;
@@ -1046,7 +1047,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
10461047
}
10471048

10481049
private _registerNotebookStickyScroll() {
1049-
this._register(this.instantiationService.createInstance(NotebookStickyScroll, this._notebookStickyScrollContainer, this, this._notebookOutline, this._list));
1050+
this._notebookStickyScroll = this._register(this.instantiationService.createInstance(NotebookStickyScroll, this._notebookStickyScrollContainer, this, this._notebookOutline, this._list));
10501051
}
10511052

10521053
private _updateOutputRenderers() {
@@ -2601,7 +2602,8 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
26012602
width: this._dimension?.width ?? 0,
26022603
height: this._dimension?.height ?? 0,
26032604
scrollHeight: this._list?.getScrollHeight() ?? 0,
2604-
fontInfo: this._fontInfo!
2605+
fontInfo: this._fontInfo!,
2606+
stickyHeight: this._notebookStickyScroll?.getCurrentStickyHeight() ?? 0
26052607
};
26062608
}
26072609

src/vs/workbench/contrib/notebook/browser/notebookViewEvents.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface NotebookLayoutInfo {
1212
height: number;
1313
scrollHeight: number;
1414
fontInfo: FontInfo;
15+
stickyHeight: number;
1516
}
1617

1718
export interface CellViewModelStateChangeEvent {

src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbarStickyScroll.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ export function registerCellToolbarStickyScroll(notebookEditor: INotebookEditor,
1515
if (cell.isInputCollapsed) {
1616
element.style.top = '';
1717
} else {
18+
const stickyHeight = notebookEditor.getLayoutInfo().stickyHeight;
1819
const scrollTop = notebookEditor.scrollTop;
1920
const elementTop = notebookEditor.getAbsoluteTopOfElement(cell);
20-
const diff = scrollTop - elementTop + extraOffset;
21+
const diff = scrollTop - elementTop + extraOffset + stickyHeight;
2122
const maxTop = cell.layoutInfo.editorHeight + cell.layoutInfo.statusBarHeight - 45; // subtract roughly the height of the execution order label plus padding
2223
const top = maxTop > 20 ? // Don't move the run button if it can only move a very short distance
2324
clamp(min, diff, maxTop) :

src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ export class NotebookStickyScroll extends Disposable {
9090
return this.domNode;
9191
}
9292

93+
getCurrentStickyHeight() {
94+
return this.currentStickyLines.size * 22;
95+
}
96+
9397
constructor(
9498
private readonly domNode: HTMLElement,
9599
private readonly notebookEditor: INotebookEditor,

0 commit comments

Comments
 (0)