Possible bug: IntelliJ removing spaces after a leading + character
I have a line that looks like this:
public String toString() {
return "Product: " + productName + " Phone: " + custPhone + " Details: " + custDetails
+ " important information: " + custInfo + " randomStuff "
+ custRandoStuff;
}
In IntelliJ code styles, I have spaces around Assignment operators and spaces around additive operators checked (along with pretty much everything else). However, when I run the formatter using Ctrl+Alt+L, I get this:
public String toString() {
return "Product: " + productName + " Phone: " + custPhone + " Details: " + custDetails
+" important information: " + custInfo + " randomStuff "
+custRandoStuff;
}
Notice that the two leading plus signs have had their spaces removed.
I know that the plus sign being used here is neither an assignment operator or an additive operator, however I couldn't find any place in settings to instruct IntelliJ whether to place the plus sign at the beginning or end of a line when line-wrapping, and whether to add a space to it or not.
Does this setting exist? If so, where? If not, is there another setting which can stop the space from being removed? Is this an intended action, or a result of some internal Regex that is looking for chars on either side of the plus sign?
Please sign in to leave a comment.
Hi tbat Please make sure that Additive operators option is enabled:
Hi Egor Klepikov. Thank you for your response. I have the additive operator checked. I also have the Unary Operator checked and the assignment operator checked. One thing to note, I am using groovy, not java.

Another interesting thing is that if I move the plus to the end of the previous line and format, I go from this.
To this:
public String toString() {return "Product: " + productName + " Phone: " + custPhone + " Details: " + custDetails +
" important information: " + custInfo + " randomStuff " +
custRandoStuff;
}
So, with the plus sign at the end, the formatting is correct. However my organization requires the plus sign to start a line, and not end it.
I've managed to reproduce the problem and raised a new issue in YouTrack, Please follow https://youtrack.jetbrains.com/issue/IDEA-277155, for updates.
Sorry for the inconvenience.