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 198424 - Formatting: "Format indentation"
Summary: Formatting: "Format indentation"
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.0
Hardware: All All
: P2 normal with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-08 03:16 UTC by pekarna
Modified: 2013-05-06 07:51 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 pekarna 2011-05-08 03:16:46 UTC
Very often, people use formatting to fix indentation, because everyone has different indentation settings, which leads to total chaos in tabs/spaces mixture.

However, formatter sometimes breaks hand-made formatting which fits the given code better - e.g. inline get/setters, space-aligned anonymous inner classes, etc.

My suggestion is:

Add a "Format indentation" which would _only_ reformat the leading spaces and tabs, taking the level of current structure depth into account.

E.g.:

     class Hello {
    public String getNote() {
 return note; }
     public void setNote( String note ) { this.note = note;
}
   }

would become
 
class Hello {
    public String getNote() {
        return note; }
    public void setNote( String note ) { this.note = note;
    }
}

and NOT

class Hello {

    public String getNote()
    {
        return note;
    }

    public void setNote( String note )
    {
        this.note = note;
    }
}

Thanks for considering.
Comment 1 pekarna 2011-05-08 03:39:08 UTC
Just found that in Options > Editor > Code Templates, there's
"On Template Expansion: Reindent Text", so perhaps there's already some code regarding re-indentation (if it's not simply "add as the same whitespace string to each line of the macro as is on the previous line" algorithm).
Comment 2 Dusan Balek 2013-05-06 07:51:15 UTC
Fixed in jet-main. Indent action added (without any shortcut initially assigned).

http://hg.netbeans.org/jet-main/rev/84747192f415