From 27284cd29ff284769b49e453b7473467881b75be Mon Sep 17 00:00:00 2001 From: sevin7676 Date: Sun, 19 Apr 2015 11:23:10 -0400 Subject: [PATCH] added completionModifier allows a highlight rule modify keyword completions --- lib/ace/mode/text.js | 6 +++++- lib/ace/mode/text_highlight_rules.js | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/ace/mode/text.js b/lib/ace/mode/text.js index f04f1722..f8f0581d 100644 --- a/lib/ace/mode/text.js +++ b/lib/ace/mode/text.js @@ -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; }); }; diff --git a/lib/ace/mode/text_highlight_rules.js b/lib/ace/mode/text_highlight_rules.js index ae72040b..fc481442 100644 --- a/lib/ace/mode/text_highlight_rules.js +++ b/lib/ace/mode/text_highlight_rules.js @@ -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, value, score, meta} + * and should return the same type or undefined to skip adding the result to + * the completion list. + */ + this.completionModifier = null; }).call(TextHighlightRules.prototype);