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 - 7.1.1, editor, java, Enter in empty method creates redundant closing curly bracket
Summary: 7.1.1, editor, java, Enter in empty method creates redundant closing curly br...
Status: RESOLVED WORKSFORME
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.1.1
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-02 16:01 UTC by ptomasek
Modified: 2012-04-03 07:40 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.