Only one visible cursor causes the editor to scroll

This commit is contained in:
Corey Johnson
2012-04-03 15:36:10 -07:00
parent a372a2b411
commit bd20d34132
4 changed files with 66 additions and 12 deletions

View File

@@ -132,11 +132,21 @@ class Cursor extends View
@setBufferPosition @editor.getEofPosition()
updateAppearance: ->
position = @editor.pixelPositionForScreenPosition(@getScreenPosition())
screenPosition = @getScreenPosition()
position = @editor.pixelPositionForScreenPosition(screenPosition)
@css(position)
if @editor.getCursors().length == 1 or @editor.screenPositionInBounds(screenPosition)
@autoScroll(position)
autoScroll: (position) ->
return if @editor._autoScrolling
@editor._autoScrolling = true
_.defer =>
@autoScrollVertically(position)
@autoScrollHorizontally(position)
@editor._autoScrolling = false
@autoScrollVertically(position)
@autoScrollHorizontally(position)
autoScrollVertically: (position) ->
linesInView = @editor.scroller.height() / @editor.lineHeight

View File

@@ -163,10 +163,10 @@ class Editor extends View
@parents('#root-view').view()
bounds: ->
rows = @height() / @lineHeight
columns = @horizontalScroller.width() / @charWidth
rows = @scroller.height() / @lineHeight
columns = @scroller.width() / @charWidth
start = new Point(@scrollTop() / @lineHeight, @horizontalScroller.scrollLeft() / @charWidth)
start = new Point(@scroller.scrollTop() / @lineHeight, @scroller.scrollLeft() / @charWidth)
end = new Point(start.row + rows, start.column + columns)
new Range(start, end)