rjsx-mode icon indicating copy to clipboard operation
rjsx-mode copied to clipboard

Wrong indentation with no parens and no semicolon

Open ezmiller opened this issue 3 years ago • 2 comments

I think this may be a bug. I am seeing the following behavior when writing jsx without parens and no semicolons:

const Component = <div>Hello World</div>
      const foo = 'foo'

It should not be indented:

const Component = <div>Hello World</div>
const foo = 'foo'

ezmiller avatar Aug 03 '21 00:08 ezmiller

Hmm, it does not reproduce on my end; I get the correct indentation. Can you provide the whole file?

felipeochoa avatar Oct 15 '21 03:10 felipeochoa

I think this is a common Emacs "issue". Not really an issue but how Emacs behave on indenting stuff with any mode as I have seem a similar behavior on cc-mode before. What I mean is, it's probably more related to electric-indent-mode than rjsx-mode.

It happens to me but as soon as I press TAB or RET on the second line, it will correct the indentation. You could probably add a hook to before-save-hook to new-line-and-indent.

(add-hook 'before-save-hook #'new-line-and-indent)

nawetimebomb avatar Jan 02 '22 05:01 nawetimebomb