Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix js2-node-get-enclosing-scope on a statement function's name #474

Merged
merged 1 commit into from
Jun 28, 2023

Commits on Jun 25, 2023

  1. Fix js2-node-get-enclosing-scope on a statement function's name

    When called with a statement function's name node,
    js2-node-get-enclosing-scope would errorneously return the function itself.
    That's not really the scope where this name is defined (it should be the
    function's parent scope).
    
    This bug affects js2-refactor's rename variable functionality.  Example:
    
        (function(){
            function |foo() {
                var |foo = 5;
                console.log(|foo);
            }
            foo();
        })();
    
    (where '|' marks possible cursor position).  Type M-x js2r-rename-var with
    the cursor on one of the marked positions, and it'll offer to rename the
    following occurrences (marked with underscores):
    
        (function(){
            function _foo_() {
                var _foo_ = 5;
                console.log(_foo_);
            }
            foo();
        })();
    
    This is incorrect, as the name is shadowed inside the function.  It should
    instead rename these two:
    
        (function(){
            function _foo_() {
                var foo = 5;
                console.log(foo);
            }
            _foo_();
        })();
    
    This patch fixes this.
    mishoo committed Jun 25, 2023
    Configuration menu
    Copy the full SHA
    c47ea93 View commit details
    Browse the repository at this point in the history