Skip to content

Commit

Permalink
Don't make server resets depend on # of files analyzed
Browse files Browse the repository at this point in the history
It causes self-repeating resets on projects with many files

Closes #146
  • Loading branch information
marijnh committed May 16, 2013
1 parent e5ee2b2 commit bf369cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/tern.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

this.handlers = Object.create(null);
this.files = [];
this.analyses = 0;
this.uses = 0;
this.pending = 0;
this.asyncError = null;
this.passes = Object.create(null);
Expand Down Expand Up @@ -108,7 +108,7 @@
},
reset: function() {
this.cx = new infer.Context(this.defs, this);
this.analyses = 0;
this.uses = 0;
for (var i = 0; i < this.files.length; ++i) clearFile(this, this.files[i]);
this.signal("reset");
},
Expand All @@ -120,7 +120,7 @@
var self = this;
doRequest(this, doc, function(err, data) {
c(err, data);
if (self.analyses > 40) {
if (self.uses > 40) {
self.reset();
analyzeAll(self, function(){});
}
Expand Down Expand Up @@ -170,6 +170,7 @@
if (!query) c(null, {});

var files = doc.files || [];
if (files.length) ++srv.uses;
for (var i = 0; i < files.length; ++i) {
var file = files[i];
ensureFile(srv, file.name, file.type == "full" ? file.text : null)
Expand Down Expand Up @@ -206,7 +207,6 @@
}

function analyzeFile(srv, file) {
++srv.analyses;
infer.withContext(srv.cx, function() {
file.scope = srv.cx.topScope;
srv.signal("beforeLoad", file);
Expand Down

0 comments on commit bf369cc

Please sign in to comment.