mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Autoscroll cursors horizontally at the model layer
Still need to respect the horizontal scroll position in the editor view
This commit is contained in:
@@ -98,18 +98,26 @@ class Cursor
|
||||
@marker.getHeadBufferPosition()
|
||||
|
||||
autoscroll: ->
|
||||
scrollMarginInPixels = @editor.getVerticalScrollMargin() * @editor.getLineHeight()
|
||||
{top, height} = @getPixelRect()
|
||||
verticalScrollMarginInPixels = @editor.getVerticalScrollMargin() * @editor.getLineHeight()
|
||||
horizontalScrollMarginInPixels = @editor.getHorizontalScrollMargin() * @editor.getDefaultCharWidth()
|
||||
{top, left, height, width} = @getPixelRect()
|
||||
bottom = top + height
|
||||
|
||||
desiredScrollTop = top - scrollMarginInPixels
|
||||
desiredScrollBottom = bottom + scrollMarginInPixels
|
||||
right = left + width
|
||||
desiredScrollTop = top - verticalScrollMarginInPixels
|
||||
desiredScrollBottom = bottom + verticalScrollMarginInPixels
|
||||
desiredScrollLeft = left - horizontalScrollMarginInPixels
|
||||
desiredScrollRight = right + horizontalScrollMarginInPixels
|
||||
|
||||
if desiredScrollTop < @editor.getScrollTop()
|
||||
@editor.setScrollTop(desiredScrollTop)
|
||||
else if desiredScrollBottom > @editor.getScrollBottom()
|
||||
@editor.setScrollBottom(desiredScrollBottom)
|
||||
|
||||
if desiredScrollLeft < @editor.getScrollLeft()
|
||||
@editor.setScrollLeft(desiredScrollLeft)
|
||||
else if desiredScrollRight > @editor.getScrollRight()
|
||||
@editor.setScrollRight(desiredScrollRight)
|
||||
|
||||
# Public: If the marker range is empty, the cursor is marked as being visible.
|
||||
updateVisibility: ->
|
||||
@setVisible(@marker.getBufferRange().isEmpty())
|
||||
|
||||
Reference in New Issue
Block a user