diff --git a/lib/ace/ext/language_tools.js b/lib/ace/ext/language_tools.js index 7133d740..d037ccb0 100644 --- a/lib/ace/ext/language_tools.js +++ b/lib/ace/ext/language_tools.js @@ -37,19 +37,10 @@ var config = require("../config"); var textCompleter = require("../autocomplete/text_completer"); var keyWordCompleter = { - getCompletions: function(session, pos, prefix, callback) { - var keywords = session.$mode.$keywordList || []; - keywords = keywords.filter(function(w) { - return w.lastIndexOf(prefix, 0) == 0; - }); - callback(null, keywords.map(function(word) { - return { - name: word, - value: word, - score: 0, - meta: "keyword" - }; - })); + getCompletions: function(editor, session, pos, prefix, callback) { + var state = editor.session.getState(pos.row); + var completions = session.$mode.getCompletions(state, session, pos, prefix); + callback(null, completions); } }; diff --git a/lib/ace/mode/text.js b/lib/ace/mode/text.js index 1af608a5..ee50d552 100644 --- a/lib/ace/mode/text.js +++ b/lib/ace/mode/text.js @@ -281,7 +281,7 @@ var Mode = function() { } } - var delegations = ['toggleCommentLines', 'getNextLineIndent', 'checkOutdent', 'autoOutdent', 'transformAction']; + var delegations = ['toggleCommentLines', 'getNextLineIndent', 'checkOutdent', 'autoOutdent', 'transformAction', 'getCompletions']; for (var i = 0; i < delegations.length; i++) { (function(scope) { @@ -356,7 +356,22 @@ var Mode = function() { return this.$keywordList; return completionKeywords.concat(this.$keywordList || []); }; - + + this.getCompletions = function(state, session, pos, prefix) { + var keywords = this.$keywordList || []; + keywords = keywords.filter(function(w) { + return w.lastIndexOf(prefix, 0) == 0; + }); + return keywords.map(function(word) { + return { + name: word, + value: word, + score: 0, + meta: "keyword" + }; + }); + }; + }).call(Mode.prototype); exports.Mode = Mode;