felipeochoa / rjsx-mode

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

Less than conditionals in curly braces seem to trip up the indenter #37

Closed geoffp closed 7 years ago

geoffp commented 7 years ago

I was seeing some wonky indentation, and I did a little sleuthing. I found that the presence of a < inside curly braces seems to cause closing tags to be misplaced. Here's an example:

import React, { Component } from 'react';

const a = 1, b = 2;

// Okay
const ExampleWithEquals = (props) => {
  return (
    <div>
      { a === b ? <span>This indentation is just dandy.</span> : null }
    </div>
  );
};

// Okay
const ExampleWithGreaterThan = (props) => {
  return (
    <div>
      { a >  b ? <span>This indentation okay, also.</span> : null }
    </div>
  );
};

// Not Okay
const ExampleWithLessThan = (props) => {
  return (
    <div>
      { a <  b ? <span>This indentation is not so nice.</span> : null }
             </div>
  );
};
felipeochoa commented 7 years ago

I think this is the same as this bug, but if not, you should file a separate one against js-mode.el For future reference, as stated in the README:

Note: This mode does not add any indentation improvements to the one built into js-mode. Please report all identation bugs there

geoffp commented 7 years ago

@felipeochoa, thanks! Will do. I bet that is the same bug.