Added setCompleters(...) function

Added setCompleters() method, so that completers can be explicitly set from a pre-populated array, or can be removed entirely (if null is passed, or setCompleters() is called without an argument or an empty array is passed.

Please check this carefully for rookie JavaScript bugs, as I'm not sure if the null/undefined test is best-practise here as I don't typically code in JavaScript in my day-job.
This commit is contained in:
takapa 2014-10-08 22:07:23 +01:00
commit 28b95df12c

View file

@ -67,8 +67,14 @@ var snippetCompleter = {
}
};
exports.removeCompleters = function() {
completers = [];
// Allows default completers to be removed or replaced with a explict set of completers
// A null argument here will result in an empty completer array, not a null attribute
exports.setCompleters = function(val) {
if (val == null || val == undefined || (!(val instanceof Array)) ) {
completers = [];
} else {
completers = val;
}
};
var completers = [snippetCompleter, textCompleter, keyWordCompleter];