ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
803 stars 54 forks source link

Advanced example doesn't work in Sublime #20

Closed TobiaszCudnik closed 11 years ago

TobiaszCudnik commented 11 years ago

Advanced example from the main demo doesn't work in Sublime. That is the following one:

// And a little more advanced code...

(function(exports) {
  exports.randomElt = function(arr) {
    return arr[Math.floor(arr.length * Math.random())];
  };
  exports.strList = "foo".split("");
  exports.intList = exports.strList.map(function(s) { return s.charCodeAt(0); });
})(window.myMod = {});

var randomStr = myMod.randomElt(myMod.strList);
var randomInt = myMod.randomElt(myMod.intList);

After typing myMod.^ I'm not getting any Tern's completion (there's the default word completion).

I'm using Tern 0.4.0. Thanks.

marijnh commented 11 years ago

I guess you don't have the browser definitions loaded, so window isn't mapped to the top-level scope, and thus the window.myMod = {} assignment isn't having the effect of defining a global variable.

Remove the window. part, or add "browser" to your .tern-project's libs setting.