tern icon indicating copy to clipboard operation
tern copied to clipboard

Renaming an argument fails if it is called after a nested function

Open MoritzKn opened this issue 9 years ago • 2 comments
trafficstars

Renaming cb won't work in this example

function foo(cb) {
    function bar() {}

    cb();
}

I'm using the ternjs Atom plugin, so perhaps it's a problem with the plugin code, but I found this unlikely.

PS: Thanks for making ternjs, it's awesome!

MoritzKn avatar Oct 01 '16 17:10 MoritzKn

Works in Emacs and Sublime Text for me. I couldn't figure out how to access the rename functionality from the Atom plugin.

marijnh avatar Oct 01 '16 20:10 marijnh

Works in Emacs and Sublime Text for me.

I've made a mistake, the problem only occurs if foo is called afterwards:

function foo(cb) {
    function bar() {}

    cb();
}

foo();

I couldn't figure out how to access the rename functionality from the Atom plugin.

In the Atom plugin it's Ctrl+Alt+Shift+C or Ctrl+Shift+P and then Atom Ternjs: Rename.

Also note: If multiple arguments are supplied, renaming works for none of them. For example here renaming works nighter for a nor b nor c:

function test(a, b, c) {
    function inner() {}

    a();

    a = 0;
    b = 0;
    c = 0;
}

test();

MoritzKn avatar Oct 02 '16 12:10 MoritzKn