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 256850 - Wrong indentation for braces
Summary: Wrong indentation for braces
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-28 21:41 UTC by matthies
Modified: 2016-04-26 06:43 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 matthies 2015-11-28 21:41:21 UTC
In certain situations, when braces placement is configured to "New Line", NetBeans determines an incorrect indentation level. Example ("<caret>" indicates the position of the caret):

class Test
{
    protected class Inner
    {
        private final Object test = new Object()
        {
            private void test()
            {
                if ("test" != null)
                    <caret>
            }
        };
    }

    @Override
    public String toString()
    {
        return super.toString();
    }
}

Typing "{" incorrectly results in:

class Test
{
    protected class Inner
    {
        private final Object test = new Object()
        {
            private void test()
            {
                if ("test" != null)
            {<caret>
            }
        };
    }

    @Override
    public String toString()
    {
        return super.toString();
    }
}

The expected result would be:

class Test
{
    protected class Inner
    {
        private final Object test = new Object()
        {
            private void test()
            {
                if ("test" != null)
                {<caret>
            }
        };
    }

    @Override
    public String toString()
    {
        return super.toString();
    }
}

Strangely, the error occurs only when the toString() method declaration is present.
Comment 1 Svata Dedic 2016-04-25 14:56:46 UTC
Seems to work OK in the trunk version; in my editor, the opening curly brace appeared aligned with the if- statement.

Please export your formatting options for java and attach them.
Comment 2 matthies 2016-04-25 16:51:22 UTC
Please try with Continuation Indentation Size set to 4. The faulty behavior doen't happen when it is set to 8, which I believe is the default, but I have it set to 4.
Comment 3 Svata Dedic 2016-04-26 06:26:51 UTC
Great, reproduced.