emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master a184642 13/22: Merge pull request #220 from jacksonrayhami


From: Dmitry Gutov
Subject: [elpa] master a184642 13/22: Merge pull request #220 from jacksonrayhamilton/comment-length
Date: Fri, 24 Apr 2015 02:57:13 +0000

branch: master
commit a184642287eb71bd0ff0c115146987ebe65613c8
Merge: 90a9056 bc61ce0
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Merge pull request #220 from jacksonrayhamilton/comment-length
    
    Fix off-by-one error for comment node length
---
 js2-mode.el     |    7 +++++--
 tests/parser.el |   12 ++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index 5424ff0..46ef97d 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -6163,8 +6163,11 @@ its relevant fields and puts it into `js2-ti-tokens'."
                              (setf (js2-token-beg token) (- js2-ts-cursor 2))
                              (js2-skip-line)
                              (setf (js2-token-comment-type token) 'line)
-                             ;; include newline so highlighting goes to end of 
window
-                             (cl-incf (js2-token-end token))
+                             ;; include newline so highlighting goes to end of
+                             ;; window, if there actually is a newline; if we
+                             ;; hit eof, then implicitly there isn't
+                             (unless js2-ts-hit-eof
+                               (cl-incf (js2-token-end token)))
                              (throw 'return js2-COMMENT))
                            ;; is it a /* comment?
                            (when (js2-match-char ?*)
diff --git a/tests/parser.el b/tests/parser.el
index d791d3f..0dd1502 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -793,3 +793,15 @@ the test."
 (js2-deftest function-without-parens-error "function b {}"
   ;; Should finish the parse.
   (js2-mode))
+
+;;; Comments
+
+(js2-deftest comment-node-length "//"
+  (js2-mode)
+  (let ((node (js2-node-at-point (point-min))))
+    (should (= (js2-node-len node) 2))))
+
+(js2-deftest comment-node-length-newline "//\n"
+  (js2-mode)
+  (let ((node (js2-node-at-point (point-min))))
+    (should (= (js2-node-len node) 3))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]