From a91183e1bb4154e418e561d2059cace6f4008218 Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 25 Nov 2020 23:28:22 +0300 Subject: [PATCH] fix scrolling in jumpToPos --- edit/codemirror-default.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/edit/codemirror-default.js b/edit/codemirror-default.js index 846a772c..cd507db6 100644 --- a/edit/codemirror-default.js +++ b/edit/codemirror-default.js @@ -128,13 +128,16 @@ * @param {CodeMirror.Pos} pos */ jumpToPos(pos) { + const {curOp} = this; + if (!curOp) this.startOperation(); const coords = this.cursorCoords(pos, 'page'); const b = this.display.wrapper.getBoundingClientRect(); - if (coords.top < b.top + this.defaultTextHeight() * 2 || - coords.bottom > b.bottom - 100) { + if (coords.top < Math.max(0, b.top + this.defaultTextHeight() * 2) || + coords.bottom > Math.min(window.innerHeight, b.bottom - 100)) { this.scrollIntoView(pos, b.height / 2); } - this.setCursor(pos, null, {scroll: false}); + this.setCursor(pos); + if (!curOp) this.endOperation(); }, });