added completionModifier
allows a highlight rule modify keyword completions
This commit is contained in:
parent
cf0c81a25f
commit
27284cd29f
2 changed files with 13 additions and 1 deletions
|
|
@ -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;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue