diff --git a/services/web/public/coffee/auto-complete/AutoCompleteManager.coffee b/services/web/public/coffee/auto-complete/AutoCompleteManager.coffee deleted file mode 100644 index 52ae4a6b49..0000000000 --- a/services/web/public/coffee/auto-complete/AutoCompleteManager.coffee +++ /dev/null @@ -1,77 +0,0 @@ -define [ - "auto-complete/SuggestionManager" - "auto-complete/Snippets" - "ace/autocomplete/util" - "ace/autocomplete" - "ace/range" - "ace/ext/language_tools" -], (SuggestionManager, Snippets, Util, AutoComplete) -> - Range = require("ace/range").Range - Autocomplete = AutoComplete.Autocomplete - - Util.retrievePrecedingIdentifier = (text, pos, regex) -> - currentLineOffset = 0 - for i in [(pos-1)..0] - if text[i] == "\n" - currentLineOffset = i + 1 - break - currentLine = text.slice(currentLineOffset, pos) - fragment = getLastCommandFragment(currentLine) or "" - return fragment - - getLastCommandFragment = (lineUpToCursor) -> - if m = lineUpToCursor.match(/(\\[^\\ ]+)$/) - return m[1] - else - return null - - class AutoCompleteManager - constructor: (@ide) -> - @aceEditor = @ide.editor.aceEditor - @aceEditor.setOptions({ - enableBasicAutocompletion: true, - enableSnippets: true - }) - - SnippetCompleter = - getCompletions: (editor, session, pos, prefix, callback) -> - callback null, Snippets - @suggestionManager = new SuggestionManager() - - @aceEditor.completers = [@suggestionManager, SnippetCompleter] - - insertMatch = Autocomplete::insertMatch - editor = @aceEditor - 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 - - @bindToEditorEvents() - - bindToEditorEvents: () -> - @ide.editor.on "change:doc", (@aceSession) => - @aceSession.on "change", (change) => @onChange(change) - - onChange: (change) -> - cursorPosition = @aceEditor.getCursorPosition() - end = change.data.range.end - # Check that this change was made by us, not a collaborator - # (Cursor is still one place behind) - if end.row == cursorPosition.row and end.column == cursorPosition.column + 1 - if change.data.action == "insertText" - range = new Range(end.row, 0, end.row, end.column) - lineUpToCursor = @aceSession.getTextRange(range) - commandFragment = getLastCommandFragment(lineUpToCursor) - - if commandFragment? and commandFragment.length > 2 - setTimeout () => - @aceEditor.execCommand("startAutocomplete") - , 0 diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index c2c79b862d..9a83b457c4 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -8,7 +8,7 @@ define [ "ide/editor/directives/aceEditor/highlights/HighlightsManager" "ide/editor/directives/aceEditor/cursor-position/CursorPositionManager" ], (App, Ace, SearchBox, UndoManager, AutoCompleteManager, SpellCheckManager, HighlightsManager, CursorPositionManager) -> - EditSession = require('ace/edit_session').EditSession + EditSession = ace.require('ace/edit_session').EditSession App.directive "aceEditor", ["$timeout", "$compile", "$rootScope", ($timeout, $compile, $rootScope) -> monkeyPatchSearch($rootScope, $compile) @@ -39,7 +39,7 @@ define [ else @$originalApply(fn); - editor = Ace.edit(element.find(".ace-editor-body")[0]) + editor = ace.edit(element.find(".ace-editor-body")[0]) window.editors ||= [] window.editors.push editor @@ -225,7 +225,7 @@ define [ ] monkeyPatchSearch = ($rootScope, $compile) -> - SearchBox = Ace.require("ace/ext/searchbox").SearchBox + SearchBox = ace.require("ace/ext/searchbox").SearchBox searchHtml = """