added completionModifier

allows a highlight rule modify keyword completions
This commit is contained in:
sevin7676 2015-04-19 11:23:10 -04:00
commit 27284cd29f
2 changed files with 13 additions and 1 deletions

View file

@ -368,14 +368,18 @@ var Mode = function() {
};
this.getCompletions = function(state, session, pos, prefix) {
var self = this;
var keywords = this.$keywordList || this.$createKeywordList();
return keywords.map(function(word) {
return {
var r = {
name: word,
value: word,
score: 0,
meta: "keyword"
};
return self.$highlightRules.completionModifier ? self.$highlightRules.completionModifier.call(self, r) : r;
}).filter(function(value) {
return value !== undefined;
});
};

View file

@ -227,6 +227,14 @@ var TextHighlightRules = function() {
this.getKeywords = function() {
return this.$keywords;
};
/**
* Function that can be set by HighlightRules to modify a keyword completion.
* The function receives {name<string>, value<string>, score<number>, meta<string>}
* and should return the same type or undefined to skip adding the result to
* the completion list.
*/
this.completionModifier = null;
}).call(TextHighlightRules.prototype);