(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 ?*)
(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))))