Merge pull request #903 from sharelatex/as-cursor-position-change-editor

Store cursor & line position when switching editor
This commit is contained in:
Jessica Lawshe 2018-09-11 10:44:24 -05:00 committed by GitHub
commit f7e4750df6
2 changed files with 8 additions and 3 deletions

View file

@ -516,6 +516,7 @@ define [
scope.$on '$destroy', () ->
if scope.sharejsDoc?
scope.$broadcast('changeEditor')
tearDownSpellCheck()
tearDownCursorPosition()
detachFromAce(scope.sharejsDoc)

View file

@ -3,12 +3,12 @@ define [], () ->
constructor: (@$scope, @adapter, @localStorage) ->
@$scope.$on 'editorInit', @jumpToPositionInNewDoc
@$scope.$on 'beforeChangeDocument', () =>
@storeCursorPosition()
@storeFirstVisibleLine()
@$scope.$on 'beforeChangeDocument', @storePositionAndLine
@$scope.$on 'afterChangeDocument', @jumpToPositionInNewDoc
@$scope.$on 'changeEditor', @storePositionAndLine
@$scope.$on "#{@$scope.name}:gotoLine", (e, line, column) =>
if line?
setTimeout () =>
@ -24,6 +24,10 @@ define [], () ->
@$scope.$on "#{@$scope.name}:clearSelection", (e) =>
@adapter.clearSelection()
storePositionAndLine: () =>
@storeCursorPosition()
@storeFirstVisibleLine()
jumpToPositionInNewDoc: () =>
@doc_id = @$scope.sharejsDoc?.doc_id
setTimeout () =>