felipeochoa / rjsx-mode

A JSX major mode for Emacs
https://github.com/felipeochoa/rjsx-mode
MIT License
641 stars 32 forks source link

multiline jsx element indentation issue #94

Closed DeeeeLAN closed 5 years ago

DeeeeLAN commented 5 years ago

If I have a react element such as this:

<XAxis                                                                  
    axisAt="bottom"                                         
    orient="bottom"                                        
    innerTickSize={-1 * 400}                               
    tickStrokeDasharray='Solid'                            
    tickStrokeOpacity={0.2}                                
    tickStrokeWidth={1}                                    
/>  

indentation doesn't work reliably on the properties. Sometimes it indents them to the correct location, but sometimes it does nothing and gives the error "Symbol's value as variable is void: sgml-attribute-offset". js2-jsx-mode does indent them, but not to the proper location.

Equally frustrating (and I think related, it gives the same error): When typing one of those properties, as soon as I type the opening bracket: {, the screen flashes and moves the cursor to the beginning of the line.

DeeeeLAN commented 5 years ago

it looks like the second issue is caused by the auto-indent kicking in when the opening brace is typed, and failing, moving the cursor.

DeeeeLAN commented 5 years ago

screen shot 2019-01-29 at 5 26 59 pm

Here is a screenshot of a snippet of code showing the default indentations. Most of these failed.

DeeeeLAN commented 5 years ago

I tried removing the 'sgml-attribute-offset' from #L1396 and so for that seems to have helped. Not sure if the issue is completely gone yet, or if I caused other issues by removing that.

darkleaf commented 5 years ago

+1