summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2014-03-10 15:17:12 +0100
committerportix <portix@gmx.net>2014-03-10 15:17:12 +0100
commit5679145e7fdcdfd0fffaf07f22ee2a4baf126d6c (patch)
tree86ed6fb65830a4b01fe3294f4a86c7ee5dce2cc9
parentcff4c66b7e16c28b657c378d78fb4c1166ddc02c (diff)
downloaddwb-5679145e7fdcdfd0fffaf07f22ee2a4baf126d6c.zip
completion: Use previous result for updates
-rw-r--r--scripts/modules/completion11
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/modules/completion b/scripts/modules/completion
index b35f7b01..0a97fc10 100644
--- a/scripts/modules/completion
+++ b/scripts/modules/completion
@@ -278,8 +278,8 @@ Object.defineProperties(Completion.prototype, {
if (text == this._lastText) {
return;
}
- this._lastText = text;
this._doUpdate(this.onUpdate(text));
+ this._lastText = text;
}
},
_onUpdateLabel : {
@@ -376,14 +376,16 @@ Object.defineProperties(Completion.prototype, {
},
_onUpdateExact : {
value : function(text) {
- return this._initialData.filter(function(item) {
+ var data = this._lastText.length < text.length ? this._data : this._initialData;
+ return data.filter(function(item) {
return item.matchAttr.indexOf(text) != -1;
});
}
},
_onUpdateLazy : {
value : function(text) {
- return this._initialData.filter(function(item) {
+ var data = this._lastText.length < text.length ? this._data : this._initialData;
+ return data.filter(function(item) {
var matchAttr = item.matchAttr;
var length = matchAttr.length;
var tmp = text;
@@ -401,8 +403,9 @@ Object.defineProperties(Completion.prototype, {
},
_onUpdateWordMatch : {
value : function(text) {
+ var data = this._lastText.length < text.length ? this._data : this._initialData;
var words = text.split(/\s+/);
- return this._initialData.filter(function(item) {
+ return data.filter(function(item) {
return words.every(function(word) {
return item.matchAttr.indexOf(word) != -1;
});