Fix StableEditorBottomScrollState (#212970)

This commit is contained in:
Alexandru Dima 2024-05-23 08:50:44 +02:00 committed by GitHub
parent 2b277fcb56
commit ba6fb3b36e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,6 +5,7 @@
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { Position } from 'vs/editor/common/core/position';
import { ScrollType } from 'vs/editor/common/editorCommon';
export class StableEditorScrollState {
@ -59,7 +60,7 @@ export class StableEditorScrollState {
}
const offset = editor.getTopForLineNumber(currentCursorPosition.lineNumber) - editor.getTopForLineNumber(this._cursorPosition.lineNumber);
editor.setScrollTop(editor.getScrollTop() + offset);
editor.setScrollTop(editor.getScrollTop() + offset, ScrollType.Immediate);
}
}
@ -78,7 +79,7 @@ export class StableEditorBottomScrollState {
if (visibleRanges.length > 0) {
visiblePosition = visibleRanges.at(-1)!.getEndPosition();
const visiblePositionScrollBottom = editor.getBottomForLineNumber(visiblePosition.lineNumber);
visiblePositionScrollDelta = (editor.getScrollTop() + editor.getLayoutInfo().height) - visiblePositionScrollBottom;
visiblePositionScrollDelta = visiblePositionScrollBottom - editor.getScrollTop();
}
return new StableEditorBottomScrollState(editor.getScrollTop(), editor.getContentHeight(), visiblePosition, visiblePositionScrollDelta);
}
@ -99,7 +100,7 @@ export class StableEditorBottomScrollState {
if (this._visiblePosition) {
const visiblePositionScrollBottom = editor.getBottomForLineNumber(this._visiblePosition.lineNumber);
editor.setScrollTop(visiblePositionScrollBottom - (this._visiblePositionScrollDelta + editor.getLayoutInfo().height));
editor.setScrollTop(visiblePositionScrollBottom - this._visiblePositionScrollDelta, ScrollType.Immediate);
}
}
}