"Reformat Code" command should respect right margin

If I set my right margin to 80 chars in Preferences > Code Style, I noticed when I reformat my code that I have split to multiple lines, WebStorm will change the code and put it on one line so it goes outside my margin.

0

What language is it about? Please provide code sample that shows up the issue

0

It's a JSX file. This is the snippet in question:

    // Validate specific field types (email, zip, etc)
    if (validate && fieldType) {
      if (target.value !== '' && !target.value.match(this.validations[this.props.fieldType])) {
        valid = this.props.weakValidation && true;
        invalidReason = this.props.invalidMsg;
      }
    }


Even if I put a newline after the &&, if I run Reformat Code, it puts it back on one line, going past the right margin (80 chars).

0

Try changing 'Binary expressions' (Settings/Code Style/javaScript/Wrapping and Braces) to 'Wrap if long'

0

That worked! You guys rock. :) There are so many options, it's sometimes hard to know what they are

Thanks!

0

请先登录再写评论。