diff options
author | Jackson Ray Hamilton <jackson@jacksonrayhamilton.com> | 2019-03-26 18:18:39 -0700 |
---|---|---|
committer | Jackson Ray Hamilton <jackson@jacksonrayhamilton.com> | 2019-04-08 22:48:23 -0700 |
commit | 55c80d43a972d3e126c173745c57a0a383bd3ad4 (patch) | |
tree | ead11eaca73d4a0e2f55ad8405ed6b28867cb6fe /test | |
parent | 16669d7c5d5a0dfadf672f8359e431ef81044a23 (diff) | |
download | emacs-55c80d43a972d3e126c173745c57a0a383bd3ad4.tar.gz |
Indent expressions in JSXAttributes relative to the attribute’s name
* lisp/progmodes/js.el (js-jsx--syntax-propertize-tag): Refer to the
beginning of a JSXExpressionContainer’s associated JSXAttribute (so
line numbers can be calculated later).
(js-jsx--text-properties): Also clear the new text property
js-jsx-expr-attribute.
(js-jsx--indenting): Remove.
(js-jsx--indent-col, js-jsx--indent-attribute-line): New variables.
(js-jsx--indentation): Instead of alternating between two separate
column calculations, neither necessarily correct, bind the JSX column
such that the second call to js--proper-indentation can use it as a
base column.
(js--proper-indentation): Use JSX as the base column for some indents
while indenting JSX.
* test/manual/indent/jsx.jsx: Add more tests for expression indents.
Diffstat (limited to 'test')
-rw-r--r-- | test/manual/indent/jsx.jsx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/manual/indent/jsx.jsx b/test/manual/indent/jsx.jsx index c2351a8cf1d..5004d57a0b1 100644 --- a/test/manual/indent/jsx.jsx +++ b/test/manual/indent/jsx.jsx @@ -68,6 +68,31 @@ return ( </div> ); +return ( + <div attribute={{ + a: 1, // Indent relative to “attribute” column. + b: 2 + } && { // Dedent to “attribute” column. + a: 1, + b: 2 + }} /> // Also dedent. +); + +return ( + <div attribute= + { // Indent properly on another line, too. + { + a: 1, + b: 2, + } && ( + // Indent other forms, too. + a ? b : + c ? d : + e + ) + } /> +) + // Indent void expressions (no need for contextual parens / commas) // (https://github.com/mooz/js2-mode/issues/140#issuecomment-166250016). <div className="class-name"> |