branch: master commit 9e7ee7708fff3ec004497a7e41c26b695bfcfad6 Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Add catch test. Don't uncolorize. --- context-coloring.el | 9 +++++++-- test/context-coloring-test.el | 8 ++++++++ test/fixtures/catch.js | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index 09bee0c..5d58ff2 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -254,13 +254,18 @@ For example: \"context-coloring-level-1-face\"." (defun context-coloring-js2-colorize () (with-silent-modifications - (context-coloring-uncolorize-buffer) + ;; (context-coloring-uncolorize-buffer) (js2-visit-ast js2-mode-ast (lambda (node end-p) (when (null end-p) (cond ((js2-scope-p node) + ;; TODO: Work on catch blocks. + ;; (message "SCOPE: %s, SPOS: %s, EPOS: %s" + ;; (js2-scope-type node) + ;; (js2-node-abs-pos node) + ;; (+ (js2-node-abs-pos node) (js2-scope-len node))) (let ((start (js2-node-abs-pos node))) (context-coloring-colorize-region start @@ -288,7 +293,7 @@ to the current buffer. Tokens are 3 integers: start, end, level. The vector is flat, with a new token occurring after every 3rd element." (with-silent-modifications - (context-coloring-uncolorize-buffer) + ;; (context-coloring-uncolorize-buffer) (let ((i 0) (len (length tokens))) (while (< i len) diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el index e1ae2e3..1218f22 100644 --- a/test/context-coloring-test.el +++ b/test/context-coloring-test.el @@ -97,6 +97,14 @@ FIXTURE." (context-coloring-mode) (context-coloring-test-region-level-p 1 10 0))) +(ert-deftest context-coloring-test-js2-mode-catch () + (context-coloring-test-js2-with-fixture + "./fixtures/catch.js" + (js2-mode) + (context-coloring-mode) + (context-coloring-test-region-level-p 1 8 0) + (context-coloring-test-region-level-p 8 20 1))) + (ert-deftest context-coloring-test-js2-mode-complexity () (context-coloring-test-js2-with-fixture "../benchmark/fixtures/mkdirp-0.5.0.js" diff --git a/test/fixtures/catch.js b/test/fixtures/catch.js new file mode 100644 index 0000000..0ead890 --- /dev/null +++ b/test/fixtures/catch.js @@ -0,0 +1 @@ +try {} catch (e) {}