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 234019 - Maximum blank lines behaves like minimum blank lines if blank lines exist
Summary: Maximum blank lines behaves like minimum blank lines if blank lines exist
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-06 13:45 UTC by MackSix
Modified: 2013-09-05 13:16 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Blank lines settings screenshot (88.06 KB, image/png)
2013-08-06 13:46 UTC, MackSix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description MackSix 2013-08-06 13:45:53 UTC
See screenshot for settings. The preview shows correctly that blank lines are removed, but the blank lines are not removed from the code unless "Maximum Blank Lines" are set to zero. 

1. Code before formatting:
---------------------------------------------------
package imports;

import java.util.*;

/**
 *
 * @author jprox
 */
public class Count {

    public int x;

    public double y;

    public String str;

    public List a;

    public LinkedList b;

    public HashMap c;

    public Map d;

    public void a() {
    }

}
--------------------------------------------------

2. After invoking Source>>Format, nothing changes!

3. Expected formatting:
--------------------------------------------------
package imports;

import java.util.*;

/**
 *
 * @author jprox
 */
public class Count {
    public int x;
    public double y;
    public String str;
    public List a;
    public LinkedList b;
    public HashMap c;
    public Map d;
    public void a() {
    }

}
---------------------------------------------------

Product Version: NetBeans IDE Dev (Build 201308052300)
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-b16
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 1 MackSix 2013-08-06 13:46:57 UTC
Created attachment 138356 [details]
Blank lines settings screenshot
Comment 2 MackSix 2013-08-06 14:13:04 UTC
I think I understand what the intent of this is, but calling them "Maximum blank lines" is misleading. They are more like "Preserve existing blank lines", not "Maximum blank lines".

It this is the way it operates, there should be a checkbook "Preserve existing blank lines" then the other two existing fields are enabled to set "Maximum preserved lines in deceleration" and "Maximum preserved lines in code".
Comment 3 Dusan Balek 2013-08-06 14:55:19 UTC
Fixed in jet-main. Label changed to 'Maximum preserved blank lines'. If you don't want to preserve the existing blank lines, use '0' as a value.

http://hg.netbeans.org/jet-main/rev/5df057c38fba
Comment 4 MackSix 2013-08-06 15:53:52 UTC
Well, I guess it is a little more complicated than that... if it is set to zero, it basically disables blank lines from working. 

I need to think about this some more, but I think it should really act like Max blank lines and add and remove blank lines to match the Min blank lines settings, but just doesn't allow any lines more than Max if Min is set higher than Max. It would behave like the preview and like v7.3.1 up to Max blank lines.

Then if you want to preserve blank line, there would be a checkbox that says: "do not remove existing lines" and it would only add lines up to Max but never remove them if you set Min lower. 

At the moment, there is no way to get the same behavior as v7.3.1 and it does not match what the preview shows.
Comment 5 MackSix 2013-08-06 20:15:59 UTC
Maybe I am assuming setting to zero still works that same and that you didn't change that part... :)
Comment 6 Dusan Balek 2013-08-07 09:06:30 UTC
The behavior has been changed to exactly follow what the label says - 'Maximum PRESERVED blank lines'. Setting to '0' means: 'do not preserve any existing blank lines (just use the limits for minimum blank lines)'.
Comment 7 Quality Engineering 2013-08-09 10:49:14 UTC
Integrated into 'main-silver', will be available in build *201308090746* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/5df057c38fba
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #234019: Maximum blank lines behaves like minimum blank lines if blank lines exist - fixed.
Comment 8 MackSix 2013-08-09 18:25:53 UTC
It is partially working. 

If "In Declaration" is set to zero then these are still disabled:

After Package
Before Imports
After Imports
After Class (Does not work after Inner Class or Inner Interface.)
After Field
After Method 

Product Version: NetBeans IDE Dev (Build 201308090746)
Java: 1.7.0_40-ea; Java HotSpot(TM) 64-Bit Server VM 24.0-b55
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-ea-b36
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 9 Dusan Balek 2013-08-12 10:40:22 UTC
OOPS.

Fixed in jet-main - second attempt.
http://hg.netbeans.org/jet-main/rev/cc4755b61815
Comment 10 Quality Engineering 2013-08-13 02:25:27 UTC
Integrated into 'main-silver', will be available in build *201308122300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/cc4755b61815
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #234019: Maximum blank lines behaves like minimum blank lines if blank lines exist - fix cont.
Comment 11 MackSix 2013-08-13 14:21:31 UTC
It works good, but I just noticed that on the outer class and functions, blank lines between Annotations and the declaration is not removed if "In Declaration" is zero. This is always removed in v7.3.1.

The blank lines between annotation and Inner Classes are removed if "In Declaration" is zero.

----------------------------------------------------------------------------

@Deprecated
           <------------------------blank line should be removed      
public MyClass {


    @Override 
             <----------------------blank line should be removed
    public String toString() {
        return null;
    }

    @SupressWarning("unchecked") <--blank line is removed for inner class
    private MyInnerClass {

    }
}

----------------------------------------------------------------------------



Product Version: NetBeans IDE Dev (Build 201308122300)
Java: 1.7.0_40-ea; Java HotSpot(TM) 64-Bit Server VM 24.0-b55
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-ea-b38
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 12 Dusan Balek 2013-08-15 09:59:52 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/aa9e4e2e6d3a
Comment 13 Quality Engineering 2013-08-16 02:40:49 UTC
Integrated into 'main-silver', will be available in build *201308152300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/aa9e4e2e6d3a
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #234019: Maximum blank lines behaves like minimum blank lines if blank lines exist - fixed.
Comment 14 MackSix 2013-08-16 12:30:45 UTC
Verified fixed in:

Product Version: NetBeans IDE Dev (Build 201308152300)
Java: 1.7.0_40-ea; Java HotSpot(TM) 64-Bit Server VM 24.0-b55
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-ea-b38
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 15 Dusan Balek 2013-09-05 13:16:52 UTC
*** Bug 235509 has been marked as a duplicate of this bug. ***