"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.
Please sign in to leave a comment.
What language is it about? Please provide code sample that shows up the issue
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).
Try changing 'Binary expressions' (Settings/Code Style/javaScript/Wrapping and Braces) to 'Wrap if long'
That worked! You guys rock. :) There are so many options, it's sometimes hard to know what they are
Thanks!