diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee index cbcdc2eac7..1488c7e4ed 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee @@ -5,6 +5,7 @@ define [ "ace/ext-language_tools" ], (SuggestionManager, SnippetManager) -> Range = ace.require("ace/range").Range + aceSnippetManager = ace.require('ace/snippets').snippetManager getLastCommandFragment = (lineUpToCursor) -> if m = lineUpToCursor.match(/(\\[^\\]+)$/) @@ -154,6 +155,25 @@ define [ if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}" editor.session.remove(range) + if !data? + completions = this.completions + popup = editor.completer.popup + data = popup.getData(popup.getRow()) + data.completer = + insertMatch: (editor, matchData) -> + console.log ">> custom insertMatch" + console.log ">> data", data + ranges = editor.selection.getAllRanges() + for range in ranges + range.start.column -= completions.filterText.length; + editor.session.remove(range); + if matchData.snippet + console.log ">> snippet" + aceSnippetManager.insertSnippet(editor, matchData.snippet); + else + console.log ">> string", matchData + editor.execCommand("insertstring", matchData.value || matchData); + Autocomplete::_insertMatch.call this, data # Overwrite this to set autoInsert = false and set font size