mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Only autoscroll to cursor when it is attached *after* reset
This commit is contained in:
@@ -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) ->
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user