Only autoscroll to cursor when it is attached *after* reset

This commit is contained in:
Nathan Sobo
2012-11-13 14:30:24 -07:00
parent bfef9077f3
commit 8aad2480b6
2 changed files with 7 additions and 6 deletions

View File

@@ -11,8 +11,10 @@ class CursorView extends View
editor: null
visible: true
autoscrollOnAttach: null
initialize: (@cursor, @editor) ->
initialize: (@cursor, @editor, options={}) ->
@autoscrollOnAttach = options.autoscroll ? true
@cursor.on 'change-screen-position.cursor-view', (screenPosition, { bufferChange, autoscroll }) =>
@updateDisplay({autoscroll})
@removeIdleClassTemporarily() unless bufferChange
@@ -23,7 +25,7 @@ class CursorView extends View
afterAttach: (onDom) ->
return unless onDom
@updateDisplay(autoscroll: false)
@updateDisplay(autoscroll: @autoscrollOnAttach)
@editor.syncCursorAnimations()
remove: ->
@@ -43,7 +45,6 @@ class CursorView extends View
@editor.pixelPositionForScreenPosition(@getScreenPosition())
autoscroll: ->
pixelPosition =
@editor.scrollTo(@getPixelPosition())
setVisible: (visible) ->

View File

@@ -642,8 +642,8 @@ class Editor extends View
getCursorViews: ->
new Array(@cursorViews...)
addCursorView: (cursor) ->
cursorView = new CursorView(cursor, this)
addCursorView: (cursor, options) ->
cursorView = new CursorView(cursor, this, options)
@cursorViews.push(cursorView)
@overlayer.append(cursorView)
cursorView
@@ -735,7 +735,7 @@ class Editor extends View
@updateLayerDimensions()
@setScrollPositionFromActiveEditSession()
@addCursorView(cursor) for cursor in @activeEditSession.getCursors()
@addCursorView(cursor, autoscroll: false) for cursor in @activeEditSession.getCursors()
@addSelectionView(selection) for selection in @activeEditSession.getSelections()
@activeEditSession.on 'add-cursor', (cursor) => @addCursorView(cursor)