diff --git a/lib/ace/autocomplete/text_completer.js b/lib/ace/autocomplete/text_completer.js index 723ff69a..6eebfc61 100644 --- a/lib/ace/autocomplete/text_completer.js +++ b/lib/ace/autocomplete/text_completer.js @@ -31,7 +31,7 @@ define(function(require, exports, module) { var Range = require("../range").Range; - var splitRegex = /[^a-zA-Z_0-9\$\-]+/; + var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/; function getWordIndex(doc, pos) { var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos)); diff --git a/lib/ace/autocomplete/util.js b/lib/ace/autocomplete/util.js index 8b7c1151..341a6b92 100644 --- a/lib/ace/autocomplete/util.js +++ b/lib/ace/autocomplete/util.js @@ -43,9 +43,9 @@ exports.parForEach = function(array, fn, callback) { callback(result, err); }); } -} +}; -var ID_REGEX = /[a-zA-Z_0-9\$-]/; +var ID_REGEX = /[a-zA-Z_0-9\$-\u007F-\uFFFF]/; exports.retrievePrecedingIdentifier = function(text, pos, regex) { regex = regex || ID_REGEX; @@ -57,7 +57,7 @@ exports.retrievePrecedingIdentifier = function(text, pos, regex) { break; } return buf.reverse().join(""); -} +}; exports.retrieveFollowingIdentifier = function(text, pos, regex) { regex = regex || ID_REGEX; @@ -69,6 +69,6 @@ exports.retrieveFollowingIdentifier = function(text, pos, regex) { break; } return buf; -} +}; }); diff --git a/lib/ace/ext/language_tools.js b/lib/ace/ext/language_tools.js index 1933b4ff..7abc2ef8 100644 --- a/lib/ace/ext/language_tools.js +++ b/lib/ace/ext/language_tools.js @@ -72,6 +72,11 @@ exports.addCompleter = function(completer) { completers.push(completer); }; +// Exports existing completer so that user can construct his own set of completers. +exports.textCompleter = textCompleter; +exports.keyWordCompleter = keyWordCompleter; +exports.snippetCompleter = snippetCompleter; + var expandSnippet = { name: "expandSnippet", exec: function(editor) { @@ -126,7 +131,7 @@ var doLiveAutocomplete = function(e) { //Try to find custom prefixes on the completers completers.forEach(function(completer) { if (completer.identifierRegexps) { - completer.identifierRegexps.forEach(function(identifierRegex){ + completer.identifierRegexps.forEach(function(identifierRegex) { if (!prefix) { prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex); } @@ -136,7 +141,7 @@ var doLiveAutocomplete = function(e) { // We don't want to autocomplete with no prefix if (e.command.name === "backspace" && !prefix) { - if (hasCompleter) + if (hasCompleter) editor.completer.detach(); } else if (e.command.name === "insertstring") { @@ -163,7 +168,7 @@ require("../config").defineOptions(Editor.prototype, "editor", { enableBasicAutocompletion: { set: function(val) { if (val) { - this.completers = completers; + this.completers = Array.isArray(val)? val: completers; this.commands.addCommand(Autocomplete.startCommand); } else { this.commands.removeCommand(Autocomplete.startCommand); @@ -171,10 +176,18 @@ require("../config").defineOptions(Editor.prototype, "editor", { }, value: false }, - enableLiveAutocomplete: { + /** + * Enable live autocomplete. If the value is an array, it is assumed to be an array of completer + * and will use them instead of the default completers. + * NOTE: Should this be renamed to enableLiveAutocompletion to match enableBasicAutocompletion? + */ + enableLiveAutocompletion: { set: function(val) { if (val) { + this.completers = Array.isArray(val)? val: completers; + // On each change automatically trigger the autocomplete + this.completers = completers; this.commands.on('afterExec', doLiveAutocomplete); } else { this.commands.removeListener('afterExec', doLiveAutocomplete); @@ -196,5 +209,4 @@ require("../config").defineOptions(Editor.prototype, "editor", { value: false } }); - });