[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9aacc44: Ignore comments and strings when recognizi
From: |
Jackson Ray Hamilton |
Subject: |
[Emacs-diffs] master 9aacc44: Ignore comments and strings when recognizing JSX |
Date: |
Sun, 22 Sep 2019 15:59:22 -0400 (EDT) |
branch: master
commit 9aacc443d9465793b96cb844469056ae80e6d91b
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Ignore comments and strings when recognizing JSX
* lisp/progmodes/js.el (js-syntax-propertize): Ignore comments and
strings.
* test/manual/indent/jsx-comment-string.jsx: New test.
---
lisp/progmodes/js.el | 6 +++++-
test/manual/indent/jsx-comment-string.jsx | 16 ++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 65a2538..3050e8f 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -2358,7 +2358,11 @@ testing for syntax only valid as JSX."
'syntax-table (string-to-syntax "\"/"))
(js-syntax-propertize-regexp end)))))
("\\`\\(#\\)!" (1 "< b"))
- ("<" (0 (ignore (if js-jsx-syntax (js-jsx--syntax-propertize-tag end))))))
+ ("<" (0 (ignore
+ (when js-jsx-syntax
+ ;; Not inside a comment or string.
+ (unless (nth 8 (save-excursion (syntax-ppss (match-beginning
0))))
+ (js-jsx--syntax-propertize-tag end)))))))
(point) end))
(defconst js--prettify-symbols-alist
diff --git a/test/manual/indent/jsx-comment-string.jsx
b/test/manual/indent/jsx-comment-string.jsx
new file mode 100644
index 0000000..37a6c32
--- /dev/null
+++ b/test/manual/indent/jsx-comment-string.jsx
@@ -0,0 +1,16 @@
+// Local Variables:
+// indent-tabs-mode: nil
+// js-indent-level: 2
+// End:
+
+// The following tests go below any comments to avoid including
+// misindented comments among the erroring lines.
+
+// The JSX-like text in comments/strings should be treated like the enclosing
+// syntax, not like JSX.
+
+// <Foo>
+void 0
+
+"<Bar>"
+void 0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 9aacc44: Ignore comments and strings when recognizing JSX,
Jackson Ray Hamilton <=