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 235228 - PHP autoindentation indefinitely adding blank lines
Summary: PHP autoindentation indefinitely adding blank lines
Status: REOPENED
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-29 11:29 UTC by unai
Modified: 2013-08-29 14:27 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 unai 2013-08-29 11:29:19 UTC
[ JDK VERSION : <1.7.0_21 ]

Use the following code snippet to reproduce:

        if ($out[0] != "null")//
            $this->popupAbortente($out, "Riga $i:");// TODO funzione

//2c II
        unset($out);


If you hit SHIFT-ALT-F to invoke autoindentation, an extra blank line is added
in the middle. If you do that again, another blank line is added, and so on
forever. So if you have a similar piece of code someplace in a big real-world
php file, as you shift-alt-F to keep your code tidy through the days, you end
up having a pageful of empty lines that got added because of this bug.

ACTUAL RESULT:

        if ($out[0] != "null")//
            $this->popupAbortente($out, "Riga $i:");// TODO funzione









//2c II
        unset($out);


EXPECTED RESULT:

        if ($out[0] != "null")//
            $this->popupAbortente($out, "Riga $i:");// TODO funzione

//2c II
        unset($out);

OR

        if ($out[0] != "null")//
            $this->popupAbortente($out, "Riga $i:");// TODO funzione

        //2c II
        unset($out);


or something like that.
Comment 1 Ondrej Brejla 2013-08-29 11:33:14 UTC
Sorry, but I can't reproduce that. Maybe your pasted code is somehow modified, so attach a sample file. Thanks.

Product Version: NetBeans IDE Dev (Build 20130829-7bb55cb231c0)
Java: 1.7.0_25; Java HotSpot(TM) Client VM 23.25-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b15
System: Linux version 3.8.0-29-generic running on i386; UTF-8; cs_CZ (nb)
Comment 2 unai 2013-08-29 11:43:12 UTC
Can reproduce in Windows 7, Windows Vista, [K]Ubuntu, CentOS 5 and 6.
Please try to do the following:
Create a new empty PHP 5.2 project (New Project... | PHP | PHP Application).
Leave everything default except for the PHP Version, where you select PHP 5.2/5.1.

Open the generated index.php and replace

// put your code here

with

        if ($out[0] != "null")//
            $this->popupAbortente($out, "Riga $i:");// TODO funzione

        //2c II
        unset($out);


Alt-shift-F and the two couples of lines of code start drifting away from each other.
Comment 3 Ondrej Brejla 2013-08-29 11:47:58 UTC
Now I can reproduce that, thanks.
Comment 4 Ondrej Brejla 2013-08-29 11:48:59 UTC
It works properly if "if" statement uses braces. May be a workaround for you.
Comment 5 Ondrej Brejla 2013-08-29 11:50:05 UTC
And when line comment before unset() is removed, then it works properly as well. That's note for me ;)
Comment 6 Ondrej Brejla 2013-08-29 11:51:21 UTC
Removing "// TODO funzione" or "//2c II" solves the problem...
Comment 7 Ondrej Brejla 2013-08-29 11:52:31 UTC
Simplest case for me:

<?php

if (true)
    foo(); //first

//second
bar();
Comment 8 unai 2013-08-29 12:04:32 UTC
Bug #235181 also is about indentation-misbehaviour after a comment; don't know if it's related though.
Comment 9 unai 2013-08-29 12:06:32 UTC
I mean, after a comment of an unbraced oneliner in an if block :)
Comment 10 Ondrej Brejla 2013-08-29 12:20:32 UTC
Hm, but it's a bit different issue. But same crap :)) I hate fixing formatter, it's a genuine hate ;)
Comment 11 mrpc 2013-08-29 14:25:34 UTC
I just tried it on windows 8 and it happens to me too.

Product Version: NetBeans IDE Dev (Build 201308270854)
Updates: Updates available
Java: 1.7.0_25; Java HotSpot(TM) 64-Bit Server VM 23.25-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b17
Comment 12 Ondrej Brejla 2013-08-29 14:27:09 UTC
Yes it will since it's platform independant ;)