[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))))
- [elpa] master dfad0d5 04/22: Merge pull request #211 from cowboyd/no-semicolon-warning-on-function-export, (continued)
- [elpa] master dfad0d5 04/22: Merge pull request #211 from cowboyd/no-semicolon-warning-on-function-export, Dmitry Gutov, 2015/04/23
- [elpa] master 02fea21 06/22: Merge pull request #213 from lelit/typos, Dmitry Gutov, 2015/04/23
- [elpa] master bf454ef 05/22: Fix typos in comments and docstrings, Dmitry Gutov, 2015/04/23
- [elpa] master 7bf479a 08/22: Fix js2-paren-node length, Dmitry Gutov, 2015/04/23
- [elpa] master 4d8ec67 07/22: Rely on bogus scopes less, Dmitry Gutov, 2015/04/23
- [elpa] master 4a1b4e8 09/22: Parse without error first method in a class with keyword name, Dmitry Gutov, 2015/04/23
- [elpa] master 90a9056 10/22: ...or any following one, Dmitry Gutov, 2015/04/23
- [elpa] master bc61ce0 11/22: Fix off-by-one error for comment node length, Dmitry Gutov, 2015/04/23
- [elpa] master 3b76567 12/22: Fix js2-node-get-enclosing-scope, Dmitry Gutov, 2015/04/23
- [elpa] master 458d3fe 14/22: Merge pull request #221 from jacksonrayhamilton/enclosing-scope, Dmitry Gutov, 2015/04/23
- [elpa] master a184642 13/22: Merge pull request #220 from jacksonrayhamilton/comment-length,
Dmitry Gutov <=
- [elpa] master 2bb4db0 15/22: Assign quote syntax to backquotes, Dmitry Gutov, 2015/04/23
- [elpa] master 4de6f03 16/22: Don't indent in multiline strings, Dmitry Gutov, 2015/04/23
- [elpa] master ee4a202 18/22: Merge pull request #195 from jacksonrayhamilton/pretty-multiline-declarations, Dmitry Gutov, 2015/04/23
- [elpa] master d4d9c54 17/22: js2-pretty-multiline-declarations: Add 'dynamic option, Dmitry Gutov, 2015/04/23
- [elpa] master 9790b97 19/22: * js2-mode.el (js2-mode): Use cursor-sensor-mode if available., Dmitry Gutov, 2015/04/23
- [elpa] master ac93b9e 21/22: Address two FIXMEs; fix a regression flagged by tests, Dmitry Gutov, 2015/04/23
- [elpa] master 022ef95 20/22: Merge commit '9790b9781aa8ca1d4bdf94d06d4e8ff2e68d37e8' into js2-mode-master, Dmitry Gutov, 2015/04/23
- [elpa] master 54df259 22/22: Merge commit 'ac93b9eef9b6ac44d187b9688d68a7a5f205b3fe' from js2-mode, Dmitry Gutov, 2015/04/23