aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/js.el35
-rw-r--r--test/manual/indent/jsx-align-gt-with-lt.jsx12
2 files changed, 43 insertions, 4 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 90f857c96fa..afdc28e53b9 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -600,6 +600,31 @@ It is set to be buffer-local (and t) when in `js-jsx-mode'."
600 :safe 'booleanp 600 :safe 'booleanp
601 :group 'js) 601 :group 'js)
602 602
603(defcustom js-jsx-align->-with-< t
604 "When non-nil, “>” will be indented to the opening “<” in JSX.
605
606When this is enabled, JSX indentation looks like this:
607
608 <element
609 attr=\"\"
610 >
611 </element>
612 <input
613 />
614
615When this is disabled, JSX indentation looks like this:
616
617 <element
618 attr=\"\"
619 >
620 </element>
621 <input
622 />"
623 :version "27.1"
624 :type 'boolean
625 :safe 'booleanp
626 :group 'js)
627
603(defcustom js-jsx-indent-level nil 628(defcustom js-jsx-indent-level nil
604 "When non-nil, indent JSX by this value, instead of like JS. 629 "When non-nil, indent JSX by this value, instead of like JS.
605 630
@@ -2725,10 +2750,12 @@ The column calculation is based off of `sgml-calculate-indent'."
2725 ;; bracket on its own line is indented at the same level as the 2750 ;; bracket on its own line is indented at the same level as the
2726 ;; opening angle bracket of the JSXElement. Otherwise, indent 2751 ;; opening angle bracket of the JSXElement. Otherwise, indent
2727 ;; JSXAttribute space like SGML. 2752 ;; JSXAttribute space like SGML.
2728 (if (progn 2753 (if (and
2729 (goto-char (nth 2 context)) 2754 js-jsx-align->-with-<
2730 (and (= line (line-number-at-pos)) 2755 (progn
2731 (looking-back "^\\s-*/?>" (line-beginning-position)))) 2756 (goto-char (nth 2 context))
2757 (and (= line (line-number-at-pos))
2758 (looking-back "^\\s-*/?>" (line-beginning-position)))))
2732 (progn 2759 (progn
2733 (goto-char (nth 1 context)) 2760 (goto-char (nth 1 context))
2734 (current-column)) 2761 (current-column))
diff --git a/test/manual/indent/jsx-align-gt-with-lt.jsx b/test/manual/indent/jsx-align-gt-with-lt.jsx
new file mode 100644
index 00000000000..8eb1d6d718c
--- /dev/null
+++ b/test/manual/indent/jsx-align-gt-with-lt.jsx
@@ -0,0 +1,12 @@
1<element
2 attr=""
3 >
4</element>
5<input
6 />
7
8// Local Variables:
9// indent-tabs-mode: nil
10// js-indent-level: 2
11// js-jsx-align->-with-<: nil
12// End: