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

Summary: Wrong indentation for braces
Product: java Reporter: matthies <matthies>
Component: SourceAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

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.