Community
Participate
Working Groups
If I open a curly brace inside a string which is in turn inside the argument list of a constructor, the curly brace appears outside the constructor, as if I were trying to anonymously subclass the class to which the constructor belongs. E.g. (^ is the caret): 1) new String(^) 2) new String("^") 3) Here I open curly braces: 3.a) What happens: new String("") {^ 3.b) What I expect: new String("{^") I'm using 3.1M6.
Smart semicolon and smart opening brace also work from the inside of String string literals. - while this is generally what you want for semicolons, the brace can be discussed - typing backspace once gives you what you expected without smartness - can be turned off on the Java>Editor>Typing preference page. - it would be too expensive to detect whether the class being references is subclassable (for example String).
Note that this doesn't appear only in string constructors, but in any constructor.
I think this is duplicated with following bugs: https://bugs.eclipse.org/bugs/show_bug.cgi?id=488244 https://bugs.eclipse.org/bugs/show_bug.cgi?id=520081 Probably the default for the preference has changed with Oxygen? In that case I would say the bug is quite severe right now.
Regarding the comments from above ... I think that the smart insertion should be working only outside of string literals. Inside string literals you just want to type. If you, for example, try to encode a little code snippet inside a string and the cursor starts jumping outside the string, then this is clearly not expected behaviour.
I'm experiencing this too, not only constructors but also lambda: when I type '{' the brace and the cursors jump to the end on the line. I need to open the file on a different editor to type that brace. How can I disable this behavior?
workaround for v4.9: Open: Preferences Navigate to page: Java->Editor->Typing Uncheck "braces" under "Automatically insert at correct position"
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
Seems to be fixed in the meantime. Not reproducible with 4.23M3
Yes, it does not occur in latest 4.23 even with automatically insert at correct position is selected for braces. Will mark this as resolved.