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 196450

Summary: Custom templates are gratuitously reformatted
Product: platform Reporter: Jesse Glick <jglick>
Component: TemplatesAssignee: Martin Entlicher <mentlicher>
Status: RESOLVED FIXED    
Severity: normal CC: gholmer
Priority: P3    
Version: 7.0   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 162526    
Bug Blocks:    

Description Jesse Glick 2011-03-08 19:46:35 UTC
I have a custom template for an NbTestCase subclass which I keep in the JUnit category. In recent builds (?) when I create a new class based on this template, it is reformatted as by Alt-Shift-F, which loses the particular pattern of whitespace and indendation I crafted for this file. While I can understand the desire to reformat stock templates according to the user's configured indentation settings, it it undesirable to do so for custom templates.

Filing here provisionally since I am not positive where this logic is implemented; I am guessing java.source/src/org/netbeans/modules/java/IndentFileEntry.java but this is old (uses org.openide.text.IndentEngine!) and may have been superseded by something else. Anyway setting <attr name="org-netbeans-modules-java-preformattedSource" boolvalue="true"/> on the template has no apparent effect.

Probably the right logic is to disable automatic indentation when templateFileObject.getAttribute("removeWritables") != null (see bug #162526 for nicer API).
Comment 1 Martin Entlicher 2011-09-18 15:45:55 UTC
*** Bug 201704 has been marked as a duplicate of this bug. ***
Comment 2 Martin Entlicher 2011-11-03 16:35:04 UTC
I've found the reformat at org.netbeans.modules.editor.EditorModule.
Comment 3 Martin Entlicher 2011-11-04 12:50:23 UTC
Fixed by changeset:   206322:a25981d2343a
http://hg.netbeans.org/main/rev/a25981d2343a
Comment 4 Quality Engineering 2011-11-05 02:58:58 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/a25981d2343a
User: mentlicher@netbeans.org
Log: #196450: Reformat only files created from the original template.