Skip to content

Commit

Permalink
Fix horizontal scrolling-into-view with non-fixed gutters
Browse files Browse the repository at this point in the history
Closes #6436
  • Loading branch information
marijnh committed Oct 9, 2020
1 parent 1cb6de2 commit cdb228a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/display/scrolling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cdb228a

Please sign in to comment.