From cdb228ac736369c685865b122b736cd0d397836c Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 9 Oct 2020 10:00:16 +0200 Subject: [PATCH] Fix horizontal scrolling-into-view with non-fixed gutters Closes #6436 --- src/display/scrolling.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/display/scrolling.js b/src/display/scrolling.js index 6d97247d92..75d6fc7ee4 100644 --- a/src/display/scrolling.js +++ b/src/display/scrolling.js @@ -91,14 +91,15 @@ function calculateScrollPos(cm, rect) { if (newTop != screentop) result.scrollTop = newTop } - let screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - let screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0) + let gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth + let screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace + let screenw = displayWidth(cm) - display.gutters.offsetWidth let tooWide = rect.right - rect.left > screenw if (tooWide) rect.right = rect.left + screenw if (rect.left < 10) result.scrollLeft = 0 else if (rect.left < screenleft) - result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)) + result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10)) else if (rect.right > screenw + screenleft - 3) result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw return result