Update autocomplete to handle custom identifier regexprsw

This commit is contained in:
William Candillon 2014-04-05 20:16:02 +02:00
commit a7297de55f
2 changed files with 12 additions and 7 deletions

View file

@ -212,7 +212,7 @@ var Autocomplete = function() {
var pos = editor.getCursorPosition();
var line = session.getLine(pos.row);
callback(null, {
prefix: util.retrievePrecedingIdentifier(line, pos.column),
prefix: util.retrievePrecedingIdentifier(line, pos.column, results.length > 0 ? results[0].identifierRegex : undefined),
matches: matches,
finished: (--total === 0)
});
@ -270,10 +270,7 @@ var Autocomplete = function() {
}.bind(this);
// Calcul prefix
var session = this.editor.getSession();
var pos = this.editor.getCursorPosition();
var line = session.getLine(pos.row);
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
var prefix = results.prefix;
// Results matches
var matches = results && results.matches;

View file

@ -122,7 +122,15 @@ var doLiveAutocomplete = function(e) {
var line = editor.session.getLine(pos.row);
var hasCompleter = editor.completer && editor.completer.activated;
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
//Try to find custom prefixes on the completors
completers.forEach(function(completer){
if(completer.identifierRegexprs){
completer.identifierRegexprs.forEach(function(identifierRegex){
prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
});
}
});
// We don't want to autocomplete with no prefix
if (e.command.name === "backspace" && !prefix) {
if (hasCompleter)
@ -185,4 +193,4 @@ require("../config").defineOptions(Editor.prototype, "editor", {
}
});
});
});