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 269142

Summary: Array Initializer wrapping with "If Long" or "Never" indent incorrectly an array with short syntax and no key
Product: php Reporter: PowerKiKi
Component: Formatting & IndentationAssignee: Tomas Mysik <tmysik>
Status: RESOLVED DUPLICATE    
Severity: normal CC: junichi11
Priority: P2    
Version: 8.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description PowerKiKi 2016-11-28 08:07:16 UTC
When using short syntax for array and declaring a nested array without any keys, and Array Initializer wrapping option is either "If Long" or "Never", then the resulting formatted code will have the opening "[" 1 indentation too far.

Most annoyingly, this will mess up correctly formatted code. So it is a regression from previous version, and as such it should be of priority P2.

Code before formatting:

$array = [
    [
        1,
        2,
    ],
];


Actual, wrong result with "If Long":

$array = [
        [
        1,
        2,
    ],
];

Actual, wrong result with "Never":

$array = [
        [
        1,
        2,
    ],
];

Actual, correct result with "Always":

$array = [
    [
        1,
        2,
    ],
];


Expected result for all option:

$array = [
    [
        1,
        2,
    ],
];


Digging in the sources I found a test for short syntax nested array (http://hg.netbeans.org/main/file/7a4ec2a1e2cd/php.editor/test/unit/data/testfiles/formatting/nested_short_array1.php), but it fails to cover the case where there is no keys declared. I believe, it should be modified to look like:

<?php
        $a = [
1 => "aaa",
    2 => "bbb",
    3 => [
4 => "a",
5 => "b"
    ],
[
"no keys"
]
  ];
?>

Probably the long syntax array should have equivalent modification.
Comment 1 Tomas Mysik 2016-11-28 08:17:41 UTC
Could you please try the dev version of NetBeans [1]? I think Junichi made some fixes in this area so it could be already fixed.

Thanks.
[1] http://bits.netbeans.org/download/trunk/nightly/latest/
Comment 2 PowerKiKi 2016-11-28 08:36:41 UTC
Indeed, I just tried the nightly build 201611240001 and it is fixed for all cases. I'll use that build for the time being.

Any approximate deadline for when it would become available publicly ?
Comment 3 Tomas Mysik 2016-11-28 09:20:40 UTC
Since it is a duplicate of issue #268171, it should (will) be part of the Patch of NetBeans 8.2 (but not sure when exactly it will be available).

Thanks for reporting.

*** This bug has been marked as a duplicate of bug 268171 ***