diff --git a/services/web/public/coffee/app/ide/editor/EditorManager.coffee b/services/web/public/coffee/app/ide/editor/EditorManager.coffee index ed331f4583..93b72212bf 100644 --- a/services/web/public/coffee/app/ide/editor/EditorManager.coffee +++ b/services/web/public/coffee/app/ide/editor/EditorManager.coffee @@ -9,7 +9,7 @@ define [ last_updated: null open_doc_id: null opening: true - cursorPosition: null + cursorPosition: {} gotoLine: null } diff --git a/services/web/public/coffee/app/ide/editor/auto-complete/AutoCompleteManager.coffee b/services/web/public/coffee/app/ide/editor/auto-complete/AutoCompleteManager.coffee index a5a13b07b5..20f451e040 100644 --- a/services/web/public/coffee/app/ide/editor/auto-complete/AutoCompleteManager.coffee +++ b/services/web/public/coffee/app/ide/editor/auto-complete/AutoCompleteManager.coffee @@ -29,19 +29,23 @@ define [ constructor: (@$scope, @editor) -> @suggestionManager = new SuggestionManager() - insertMatch = Autocomplete::insertMatch - editor = @editor - Autocomplete::insertMatch = (data) -> - pos = editor.getCursorPosition() - range = new Range(pos.row, pos.column, pos.row, pos.column + 1) - nextChar = editor.session.getTextRange(range) + if !Autocomplete::_insertMatch? + # Only override this once since it's global but we may create multiple + # autocomplete handlers + Autocomplete::_insertMatch = Autocomplete::insertMatch + Autocomplete::insertMatch = (data) -> + pos = editor.getCursorPosition() + range = new Range(pos.row, pos.column, pos.row, pos.column + 1) + nextChar = editor.session.getTextRange(range) - # If we are in \begin{it|}, then we need to remove the trailing } - # since it will be adding in with the autocomplete of \begin{item}... - if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}" - editor.session.remove(range) - - insertMatch.call editor.completer, data + console.log "INSERT MATCH", this + + # If we are in \begin{it|}, then we need to remove the trailing } + # since it will be adding in with the autocomplete of \begin{item}... + if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}" + editor.session.remove(range) + + Autocomplete::_insertMatch.call this, data @$scope.$watch "autoComplete", (autocomplete) => console.log "autocomplete change", autocomplete diff --git a/services/web/public/coffee/app/ide/editor/cursor-position/CursorPositionManager.coffee b/services/web/public/coffee/app/ide/editor/cursor-position/CursorPositionManager.coffee index be90f8fcec..27f7045d77 100644 --- a/services/web/public/coffee/app/ide/editor/cursor-position/CursorPositionManager.coffee +++ b/services/web/public/coffee/app/ide/editor/cursor-position/CursorPositionManager.coffee @@ -13,9 +13,9 @@ define [], () -> @editor.on "changeSelection", () => cursor = @editor.getCursorPosition() - console.log "Updating cursor position", cursor @$scope.$apply () => - @$scope.cursorPosition = cursor + if @$scope.cursorPosition? + @$scope.cursorPosition = cursor @$scope.$watch "gotoLine", (value) => console.log "Going to line", value diff --git a/services/web/public/coffee/app/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/app/ide/editor/directives/aceEditor.coffee index d7235ce771..594dd632f8 100644 --- a/services/web/public/coffee/app/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/app/ide/editor/directives/aceEditor.coffee @@ -42,7 +42,9 @@ define [ else @$originalApply(fn); - window.editor = editor = Ace.edit(element.find(".ace-editor-body")[0]) + editor = Ace.edit(element.find(".ace-editor-body")[0]) + window.editors ||= [] + window.editors.push editor autoCompleteManager = new AutoCompleteManager(scope, editor, element) spellCheckManager = new SpellCheckManager(scope, editor, element) diff --git a/services/web/public/coffee/auto-complete/AutoCompleteManager.coffee b/services/web/public/coffee/auto-complete/AutoCompleteManager.coffee index 52ae4a6b49..fbc90f0324 100644 --- a/services/web/public/coffee/auto-complete/AutoCompleteManager.coffee +++ b/services/web/public/coffee/auto-complete/AutoCompleteManager.coffee @@ -47,6 +47,8 @@ define [ range = new Range(pos.row, pos.column, pos.row, pos.column + 1) nextChar = editor.session.getTextRange(range) + console.log "CALLING OLD" + # If we are in \begin{it|}, then we need to remove the trailing } # since it will be adding in with the autocomplete of \begin{item}... if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}"