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 110200 - New class from template is not formatted correctly
Summary: New class from template is not formatted correctly
Status: RESOLVED DUPLICATE of bug 115983
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
: 118080 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-07-18 20:09 UTC by hobel
Modified: 2007-11-05 13:39 UTC (History)
2 users (show)

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 hobel 2007-07-18 20:09:14 UTC
NB6 M10, Java 1.6.0_02, Linux/Gtk

Because I want my indentation to be flexible (so one user can set a block indent to two spaces,
another to four or eight), I told NetBeans to use tabs instead of spaces, and to NOT expand tabs to spaces.

I have indentation/tab/whatever settings of four spaces per tab, which is my personal viewing preference.

When I create a new class (for which NB uses a template), or when I use the alt-enter shortcut for "implementing
all abstract/interface functions", however, NetBeans indents everything generated with spaces.

Also, while in an earlier milestone I remember being able to insert tabs into the template (which were unfortunately
ignored during expansion/use of that template, in NB6 M10 I can no longer even insert tabs into templates.  Pressing
tab inserts four spaces (whyever it should do that).

This is about the only thing that annoys me with NetBeans (and the only area where Eclipse has very reasonable
default settings).  While it's pointless to argue spaces vs tabs, I think that the IDE should respect the user's
code style preferences.
Comment 1 Jan Lahoda 2007-07-20 09:37:12 UTC
Reporter, please see also issue #66187.
Comment 2 hobel 2007-07-20 17:09:54 UTC
Yes, thanks.  I'm aware of the "hidden" tab setting, but even setting everything to 4 doesn't help.
If I don't set the hidden tab setting, NB indents a 8-space tab when I press "tab", so I've set it to 4 for a
while now, which at least does what I want for normal coding.

Templates use spaces, though, as does auto-generated code.  (Not sure, IIRC NB 5 used to work, but the new Java
editor, which is otherwise great, broke things.)
Comment 3 dooder0001 2007-08-07 13:50:21 UTC
I have to say that this issue is very irritating. It seems that the templates should be indentation-independent. There
are many indentation settings and I'd expect NetBeans to honor them when inserting templates. It seems that an easy fix
would be to strip indentation from templates and have NetBeans auto-indent them with its Reformat Code feature.
Comment 4 Dusan Balek 2007-08-09 10:09:22 UTC
The "New From Template" action still uses the old IndentEngine instead of the new ReformatTask to format the newly
created source. Reassigning to Mila.
Comment 5 Vitezslav Stejskal 2007-10-08 11:48:48 UTC
*** Issue 118080 has been marked as a duplicate of this issue. ***
Comment 6 Vitezslav Stejskal 2007-10-17 17:25:53 UTC
Yeah, 'Generate Code' seems to reformat created code properly. It's just when creating new java class the code is not
reformatted. Honzo, any idea where this should be fixed? Is this controlled by java (in JavaDataObject or something
else) or does the editor infrastructure have control over it? Thanks
Comment 7 Jan Pokorsky 2007-10-17 17:46:21 UTC
Mila promised to fix it in issue #115983.

*** This issue has been marked as a duplicate of 115983 ***