ternjs / tern_for_vim

Tern plugin for Vim
MIT License
1.83k stars 100 forks source link

Autocompletion with multiple files #56

Closed mklinga closed 10 years ago

mklinga commented 10 years ago

Hi! I stumbled into a small issue. I think I'm best off showing how to reproduce it:

file1.js:

function A() { this.num = 1; }

file2.js:

var instance = new A();

now at file1.js:

instance.

provides no completion options even though :TernDef finds correct declaration in file2.js, and from there :TernDef finds function A() correctly in file1.js. After I have restarted vim (and thus tern server) with "loadEagerly": "*.js" completion in file1.js works as supposed to. Without loadEagerly this doesn't happen even if I open both files.

After reloading, completion on instance works until I change function A(). After that autocompletion can't find changed contents of instance anymore, which, I think, is understandable since it's now a different object.

So what I'm basically asking is if there is some way to "refresh" all files in the project for tern? Only relation between these files is that they happen to be in the same folder, so no require()-magic or anything like that.

marijnh commented 10 years ago

Currently, killall node is the way to force a full reload. I wasn't able to reproduce this problem. The kind of circular dependency (file 1 using an instance from file 2 of a constructor it itself defines) is sort of rare, but theoretically, it should work (the new value for variable A should propagate to the new in file 2, and thus update the type of the object in instance). Are you using the current (git) version of Tern? There were some fixes to the mechanism that refreshes variables a few months ago.

mklinga commented 10 years ago

Sorry for long delay in answering, this seems to be no longer relevant (I cannot reproduce the issue anymore), so this may be closed.