branch: master commit 3b765677df64dd1ec5692b52cf6382910ccf293b Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Fix js2-node-get-enclosing-scope Previously this function discriminated against nodes that did not have parents. For such nodes, nil should have been returned, but instead an error was emitted because a parentless node would produce the initial parent nil, which would cause js2-node-parent to blow up. This fixes that. --- js2-mode.el | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index 5424ff0..41bc507 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -2307,10 +2307,9 @@ If any given node in NODES is nil, doesn't record that link." (defun js2-node-get-enclosing-scope (node) "Return the innermost `js2-scope' node surrounding NODE. Returns nil if there is no enclosing scope node." - (let ((parent (js2-node-parent node))) - (while (not (js2-scope-p parent)) - (setq parent (js2-node-parent parent))) - parent)) + (while (and (setq node (js2-node-parent node)) + (not (js2-scope-p node)))) + node) (defun js2-get-defining-scope (scope name &optional point) "Search up scope chain from SCOPE looking for NAME, a string or symbol.