branch: master commit 1c0155f575ae8733980c3449938102bde2f72fb5 Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Don't color name nodes in their own scope. --- context-coloring.el | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index ac941db..56e3e28 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -250,15 +250,6 @@ END (exclusive) with the face corresponding to LEVEL." (setq current-scope enclosing-scope)) (puthash scope level context-coloring-js2-scope-level-hash-table))))) -(defsubst context-coloring-js2-name-node-level (node) - (cond ((js2-node-top-level-decl-p node) - 0) - (t - (context-coloring-js2-scope-level - (js2-get-defining-scope - (js2-node-get-enclosing-scope node) - (js2-name-node-name node)))))) - (defsubst context-coloring-js2-local-name-node-p (node) "Determines if NODE is a js2-name-node representing a local variable." @@ -298,9 +289,18 @@ generated by js2-mode." node (context-coloring-js2-scope-level node))) ((context-coloring-js2-local-name-node-p node) - (context-coloring-js2-colorize-node - node - (context-coloring-js2-name-node-level node)))) + (let* ((enclosing-scope (js2-node-get-enclosing-scope node)) + (defining-scope (js2-get-defining-scope + enclosing-scope + (js2-name-node-name node)))) + ;; The tree seems to be walked lexically, so an entire scope will + ;; be colored, including its name nodes, before they are + ;; reached. Coloring the nodes defined in that scope would be + ;; redundant, so don't do it. + (when (not (eq defining-scope enclosing-scope)) + (context-coloring-js2-colorize-node + node + (context-coloring-js2-scope-level defining-scope)))))) ;; The `t' indicates to search children. t)))))