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 130702 - Formatting of spaces is forced upon the coder
Summary: Formatting of spaces is forced upon the coder
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 4 votes (vote)
Assignee: Dusan Balek
URL:
Keywords:
: 168733 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-03-20 18:29 UTC by zdro
Modified: 2016-09-13 16:52 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zdro 2008-03-20 18:29:58 UTC
Product Version: NetBeans IDE 6.1 Beta (Build 200803050202)
Java: 1.6.0_02; Java HotSpot(TM) Client VM 1.6.0_02-b05
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)


The Formatting -> Spaces is always active; I can not find a way to disable it.

The config page allows me to configure 0 or 1 space for each given element.  I think this is a good direction, but I 
have a big problem with the fact that the only choices are 0 or 1, and that I cannot disable it.  

This takes control away from the developer, and there is no workaround (other than to indent all of my lines manually).

Here is an example:

Very readable code (IMHO) _before_ formatting:

    void func()
    {
        int    var_one  =  2;
        String var_2    = "string";
        Data   data     = new Data();
        
        data.description = "described";
        data.index       = 1;
        data.message     = new Object();
    }

Somewhat LESS readable code after formatting:

    void func()
    {
        int var_one = 2;
        String var_2 = "string";
        Data data = new Data();

        data.description = "described";
        data.index = 1;
        data.message = new Object();
    }

Notice that my assignment statements have all been scrunched in.  This makes it harder to read through series of 
assignment statements, or other series of similar statements.

Please know that my intent is not to start some sort of flame war over what is/is not "proper" formatting.  But I make 
a conscious effort to make my code organized and easy to read.  Lining things up, as in the "before" snip, is a very 
simple way to do that.  I imagine that was the motivation for the options that line up method 
parameters, 'extends/implements' lists, etc...

Possibilities:

1. Allow the user to disable this (mandatory, IMO)
2. Allow me to configure 0, 1, or "at least 1" space (a VERY useful option)
3. Make the formatter smart enough to recognize things that are lined up (overkill?)
Comment 1 Vitezslav Stejskal 2008-03-25 11:39:58 UTC
Yes, we should definitely support this. It was already filed as an RFE for java editor. Thanks

*** This issue has been marked as a duplicate of 129817 ***
Comment 2 zdro 2008-03-25 13:12:52 UTC
Is this really a duplicate?  129817 seems to be the reverse of this.  It is a request for the formatter to do the 
lining up automatically.  The issue here is that the spacing by the formatter can't be turned off.

The enhancement in 129817 will be a nice addition.  But it will probably not handle every possible case, and it sounds 
like a much harder problem to solve.  If the formatter isn't doing what the coder wants, shouldn't there still be a 
way to turn it off?  

I really feel that the first step should be to give control back to the developer.  Enable the user to disable the 
formatter's spacing, or have the "at least X spaces" option.  

Or how about an "indent only" command that indents without reformatting?

I hope you will consider this further.  Thanks.
Comment 3 Vitezslav Stejskal 2008-03-25 16:23:46 UTC
Uh, I'm sorry, I really misunderstood this. As for #1 and #2 I think they could be implemented together in form of a
selection for each option that now has a tick box. The #3 is IMO what issue #129817 is about. If you line up
declarations like that, you probably want to tell the formatter to do this automatically for you. Please don't expect
this to get implemented for Nb 6.1.
Comment 4 zdro 2008-03-25 22:39:37 UTC
I'm glad I pressed.  :)

Agreed on #3.  I look forward to #1 and #2 sometime after 6.1.  (hopefully, soon after)

Thanks!
Comment 5 lytles 2008-04-19 03:35:21 UTC
this is very important to me as well (#1 and #2).

also, atleast for #1, it shouldn't be a RFE, it's a regression. nb5.5 was able to indent without destroying the
carefully hand-formatted lines.

#3 would be nice, but is far from necessary, where it's difficult to write code without #1.

that said, the format engine does a really nice job most of the time, so being able to apply it (the full thing, like it
is now) to a region (presumably that i haven't hand formatted), would be a nice feature.

not sure if #1 above covers this case that's of interest to me:

i'd like to be able to have:

public foobar() { /* stuff */ }

and have that left intact (nb5.5 handled this as well)






Comment 6 Jiri Prox 2008-12-04 13:24:00 UTC
*** Issue 154590 has been marked as a duplicate of this issue. ***
Comment 7 liono 2009-03-01 15:47:04 UTC
I wonder if <a href="http://www.netbeans.org/issues/show_bug.cgi?id=123560">Issue 123560</a> shouldn't be "bundled" or
something with this one since both basically request the same thing: being able to toggle specific formatting aspects
(lines, spaces, etc.).
Comment 8 Jiri Prox 2009-07-20 18:16:51 UTC
*** Issue 168733 has been marked as a duplicate of this issue. ***