Skip to content

Commit 9423df5

Browse files
committed
Improve update of ctags
1 parent 78d33d9 commit 9423df5

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

core/cb.codecomplete.ctags/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function setup(options, imports, register) {
1515

1616
// Create codecomplete index
1717
codecomplete.addIndex("ctags", populate, {
18-
interval: 10*60*1000
18+
interval: 60*1000
1919
})
2020

2121
register(null, {});

core/cb.codecomplete/codecomplete.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,16 @@ CodeComplete.prototype.addHandler = function(name, handler) {
4848
CodeComplete.prototype.addIndex = function(name, populate, options) {
4949
var that = this;
5050
var index = null;
51-
var _isPopulating = false;
51+
var inProgress = null;
5252

5353
options = _.defaults({}, options || {}, {
54-
'interval': 1*60*1000 // 1 minute
54+
'interval': 60*1000 //1min
5555
})
5656

5757
var populateIndex = function() {
58-
if (_isPopulating) {
59-
return Q.reject(new Error(name+": Already working on populating the index"));
60-
}
61-
_isPopulating = true;
62-
return Q(populate({
58+
if (inProgress) return inProgress;
59+
60+
inProgress = Q(populate({
6361
'root': that.workspace.root,
6462
'project': that.project
6563
})).then(function(items) {
@@ -68,8 +66,10 @@ CodeComplete.prototype.addIndex = function(name, populate, options) {
6866
index = null;
6967
return Q.reject(err);
7068
}).fin(function() {
71-
_isPopulating = false;
72-
})
69+
inProgress = null;
70+
});
71+
72+
return inProgress;
7373
};
7474

7575
// Populate the index when there are changes
@@ -83,11 +83,14 @@ CodeComplete.prototype.addIndex = function(name, populate, options) {
8383
this.addHandler(name, function(options) {
8484
var prepare = Q();
8585

86-
// if no ndex yet: populate the index
86+
// if no index yet: populate the index
8787
if (!index) {
8888
prepare = populateIndex();
8989
}
9090

91+
// If processing new data, wait for new update
92+
if (inProgress) prepare = inProgress;
93+
9194
// Filter the index for getting the results
9295
return prepare.then(function() {
9396
// Filter is done by the 'get'

0 commit comments

Comments
 (0)