inline chat stable scroll should ensure first line stays visible (#216705)

This commit is contained in:
Johannes Rieken 2024-06-20 13:05:30 +02:00 committed by GitHub
parent 4795e48fb5
commit 07dcb7aff4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -184,12 +184,21 @@ export class InlineChatZoneWidget extends ZoneWidget {
const lineTop = this.editor.getTopForLineNumber(lineNumber);
const zoneTop = lineTop - height.pixelsValue;
// const spaceBelowLine = this.editor.getScrollHeight() - this.editor.getBottomForLineNumber(position.lineNumber);
// const minTop = this.editor.getScrollTop() - spaceBelowLine;
// const newTop = Math.max(zoneTop, minTop);
const newTop = zoneTop;
const editorHeight = this.editor.getLayoutInfo().height;
const newLineBottom = this.editor.getBottomForLineNumber(lineNumber);
let newTop: number;
if (newLineBottom > editorHeight) {
newTop = newLineBottom - editorHeight;
} else {
newTop = zoneTop;
}
const currentTop = this.editor.getScrollTop();
// console.log('REVEAL ZONE TOP', { zoneTop, newLineBottom, editorHeight, currentTop, newTop });
if (newTop < currentTop) {
this.editor.setScrollTop(newTop, ScrollType.Immediate);
}