This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I have the following as a Code Template... try { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { ${selection} } }); } catch (Exception ex) { //TO DO: add exception handler } However, when the code is inserted there is an extra line break added... try { java.awt.EventQueue.invokeLater(new Runnable() { <<<< extra line break public void run() { ... } Try as I might, I cannot prevent it.
Reassigning to "editor".
This is caused by automatic reformat when code template is applied. I think we should have an option for this since some users prefers it and some not.
Please change your formatting settings in Tools-Options -> Java Code -> Formatting -> Blank Lines -> Before method. The options has been requested in issue #131227. *** This issue has been marked as a duplicate of 131227 ***
That has made no difference. I had tried that previously before submitting this issue.
Further to that last comment of mine, why should any of those settings be considered in the case of Code Templates? If I want blank lines in my templates, I'll put them in when I create it. If I don't then I won't put them in. It seems to me to be adding complexity for no good reason.
> That has made no difference. You are right, sorry. > Further to that last comment of mine, why should any of those settings be considered in the case of Code Templates? Code templates are formatted when expanded, which is what most people want. In some cases templates should only be indented or perhaps even expanded 'as-is', please see issue #136074 for the discussion about this.
The setting that needs to changed is Tools-Options -> Java Code -> Formatting -> Blank Lines -> After Class Header. There is a request to split this option into two - one for standalone classes, second for anonymous inner classes. See issue #121127. *** This issue has been marked as a duplicate of 121127 ***