From 80388a73995f4a989ac6083284fe8af528dd3aec Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 3 Mar 2023 18:04:53 -0800 Subject: [PATCH] scroll to bottom if anchorline is not found --- src/main.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index 67c73c60b..208fb00a8 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1633,7 +1633,13 @@ class LinesView extends React.Component<{sw : ScreenWindow, width : number, line componentDidMount() : void { let {sw, lines} = this.props; - if (sw.anchorLine == null) { + let linesElem = this.linesRef.current; + let anchorLineObj = sw.getLineByNum(sw.anchorLine); + if (anchorLineObj == null) { + // scroll to bottom + if (linesElem != null) { + linesElem.scrollTop = linesElem.clientHeight; + } this.computeAnchorLine(); } else { @@ -1642,7 +1648,6 @@ class LinesView extends React.Component<{sw : ScreenWindow, width : number, line this.lastSelectedLine = sw.getSelectedLine(); this.lastLinesLength = lines.length; - let linesElem = this.linesRef.current; if (linesElem != null) { this.lastOffsetHeight = linesElem.offsetHeight; this.lastOffsetWidth = linesElem.offsetWidth;