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.

Bug 210560

Summary: 7.1.1, editor, java, Enter in empty method creates redundant closing curly bracket
Product: editor Reporter: ptomasek
Component: Formatting & IndentationAssignee: Dusan Balek <dbalek>
Status: RESOLVED WORKSFORME    
Severity: normal    
Priority: P2    
Version: 7.1.1   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

Description ptomasek 2012-04-02 16:01:22 UTC
Pressing Enter after the opening curly bracket at the beginning of an empty method which has the closing curly bracket already in place results into two closing curly brackets, which makes an incorrect Java code.

Steps to reproduce:

a) Create a new Java class file.
b) Write the below three lines of code.
c) Place the cursor at the end of line 2.
d) Press Enter.

Code (lines begin with line number):

1    public class A  {
2        public boolean execute() {
3        }

Expected result:

1    public class A  {
2        public boolean execute() {
3
4        }

Actual result:
1    public class A  {
2        public boolean execute() {
3
4        }
5        }
Comment 1 Dusan Balek 2012-04-03 07:15:11 UTC
The Bracket Completion is one of the features of the NetBeans Java editor, which from an incorrect Java code creates the syntactically correct one (see your test case). However, if you don't like this feature, you can turn it off via 'Tools -> Options -> Editor -> Code Completion -> Insert Closing Brackets Automatically'. Closing as WORKSFORME.
Comment 2 ptomasek 2012-04-03 07:40:17 UTC
Oh, I see. The indentation confused me.