emacstern

Jump to definition does not work on objects defined as property on window


In my tern set up in emacs, this code works fine when I do M-. when my cursor is under the foo of obj.foo() (in the last line):

var obj = {};
obj.foo = function() {
    return true;
};

obj.foo();

But when I do the same on the following, it says "No definition found."

window.obj = {};
obj.foo = function() {
    return true;
};

obj.foo();

I tried making each refernce to obj as window.obj. Doesn't seem to help. Am I missing something?


Solution

  • It seems that your problem is that you don't use browser JSON Type Definition which defines window object. Your .tern-project should look like this :

    {"libs":["ecma5","browser"]}
    

    I have tried without browser and I have the same problem than you. If I declare browser, it works great.