diff --git a/services/web/public/coffee/ide/editor/EditorManager.coffee b/services/web/public/coffee/ide/editor/EditorManager.coffee index 4d0f965d93..2eb7cd1384 100644 --- a/services/web/public/coffee/ide/editor/EditorManager.coffee +++ b/services/web/public/coffee/ide/editor/EditorManager.coffee @@ -38,7 +38,7 @@ define [ done = () => if options.gotoLine? - @$scope.editor.gotoLine = options.gotoLine + @$scope.$broadcast "editor:gotoLine", options.gotoLine if doc.id == @$scope.editor.open_doc_id and !options.forceReopen @$scope.$apply () => diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index 1b1eb35430..dda831bb53 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -46,8 +46,8 @@ define [ scope.name = attrs.aceEditor - # autoCompleteManager = new AutoCompleteManager(scope, editor, element) - # spellCheckManager = new SpellCheckManager(scope, editor, element) + autoCompleteManager = new AutoCompleteManager(scope, editor, element) + spellCheckManager = new SpellCheckManager(scope, editor, element) undoManager = new UndoManager(scope, editor, element) highlightsManager = new HighlightsManager(scope, editor, element) cursorPositionManager = new CursorPositionManager(scope, editor, element) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/cursor-position/CursorPositionManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/cursor-position/CursorPositionManager.coffee index b882b6d7b5..2b8692be96 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/cursor-position/CursorPositionManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/cursor-position/CursorPositionManager.coffee @@ -3,47 +3,49 @@ define [], () -> constructor: (@$scope, @editor, @element) -> @editor.on "changeSession", (e) => - e.session.on "changeScrollTop", (e) => - @onScrollTopChange(e) + if e.oldSession? + @storeCursorPosition(e.oldSession) + @storeScrollTopPosition(e.oldSession) + + @doc_id = @$scope.sharejsDoc?.doc_id e.session.selection.on 'changeCursor', (e) => - @onCursorChange(e) + @emitCursorUpdateEvent(e) - @gotoStoredPosition() + setTimeout () => + @gotoStoredPosition() + , 0 - @$scope.$watch "gotoLine", (value) => + $(window).on "unload", () => + @storeCursorPosition(@editor.getSession()) + @storeScrollTopPosition(@editor.getSession()) + + @$scope.$on "#{@$scope.name}:gotoLine", (editor, value) => console.log "Going to line", value if value? setTimeout () => @gotoLine(value) - @$scope.$apply () => - @$scope.gotoLine = null , 0 - onScrollTopChange: (event) -> - if !@ignoreCursorPositionChanges and doc_id = @$scope.sharejsDoc?.doc_id - docPosition = $.localStorage("doc.position.#{doc_id}") || {} - docPosition.scrollTop = @editor.getSession().getScrollTop() - $.localStorage("doc.position.#{doc_id}", docPosition) + storeScrollTopPosition: (session) -> + if @doc_id? + docPosition = $.localStorage("doc.position.#{@doc_id}") || {} + docPosition.scrollTop = session.getScrollTop() + $.localStorage("doc.position.#{@doc_id}", docPosition) + + storeCursorPosition: (session) -> + if @doc_id? + docPosition = $.localStorage("doc.position.#{@doc_id}") || {} + docPosition.cursorPosition = session.selection.getCursor() + $.localStorage("doc.position.#{@doc_id}", docPosition) - onCursorChange: (event) -> - @storeCursorPosition() - @emitCursorUpdateEvent() - - storeCursorPosition: () -> - if !@ignoreCursorPositionChanges and doc_id = @$scope.sharejsDoc?.doc_id - docPosition = $.localStorage("doc.position.#{doc_id}") || {} - docPosition.cursorPosition = @editor.getCursorPosition() - $.localStorage("doc.position.#{doc_id}", docPosition) - emitCursorUpdateEvent: () -> cursor = @editor.getCursorPosition() @$scope.$emit "cursor:#{@$scope.name}:update", cursor gotoStoredPosition: () -> - doc_id = @$scope.sharejsDoc?.doc_id - return if !doc_id? - pos = $.localStorage("doc.position.#{doc_id}") || {} + return if !@doc_id? + pos = $.localStorage("doc.position.#{@doc_id}") || {} @ignoreCursorPositionChanges = true @editor.moveCursorToPosition(pos.cursorPosition or {row: 0, column: 0}) @editor.getSession().setScrollTop(pos.scrollTop or 0) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee index e8b3a97a0f..7d4b73730d 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee @@ -29,8 +29,6 @@ define [ $(document).on "click", (e) => @closeContextMenu(e) return true - # $(document).on "contextmenu", (e) => - # @closeContextMenu(e) @$scope.replaceWord = (highlight, suggestion) => @replaceWord(highlight, suggestion) @@ -39,13 +37,11 @@ define [ @learnWord(highlight) runFullCheck: () -> - console.log "Running full check" @highlightedWordManager.clearRows() if @$scope.spellCheckLanguage and @$scope.spellCheckLanguage != "" @runSpellCheck() runCheckOnChange: (e) -> - console.log "Checking change", e.data if @$scope.spellCheckLanguage and @$scope.spellCheckLanguage != "" @highlightedWordManager.applyChange(e.data) @markLinesAsUpdated(e.data)