ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
801 stars 52 forks source link

Lazy file loading #58

Closed lebedev closed 9 years ago

lebedev commented 9 years ago

I have a test folder with 2 files: a.js and b.js: a.js contents:

var obj_a = {
    test_a: function() {}
};

b.js contents:

var obj_b = {
    test_b: function() {}
};

I open those two files, enter obj_ in a.js and there's not obj_b: pic. 1

Ok, I switch to b.js. It has obj_a in auto-completion list: pic. 2 Sometimes there are objects from both files in auto-completion list in file a.js, and there's only obj_b in b.js, like b.js was loaded in tern and a.js wasn't. It seems like I have to show some activity in one file for it to load in tern, like entering a text, trigger auto-completion or saving it. I don't know.

marijnh commented 9 years ago

Yes, files are only pushed to the inference engine when:

In your situation, I think adding a loadEagerly option (maybe using wilcards, like test/*.js), is the way to go.

lebedev commented 9 years ago

You run a query on them from your editor

Thanks for the answer. But the docs say that

By default, local files are loaded into the Tern server when they are opened by the editor.

which turns out to be untrue. Maybe you should edit that sentence about file loading and specify that conditions?

marijnh commented 9 years ago

That's a good point. Attached patch should help there.