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 184923 - All file templates contain unix line endings (LF), that makes all new files on Windows incorrect
Summary: All file templates contain unix line endings (LF), that makes all new files o...
Status: RESOLVED WONTFIX
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 6.x
Hardware: PC All
: P4 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on: 115983
Blocks:
  Show dependency tree
 
Reported: 2010-04-25 10:28 UTC by galet
Modified: 2016-07-07 07:29 UTC (History)
3 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 galet 2010-04-25 10:28:07 UTC
Scenario:

when you create for example a new class a file defined in Tools -> Templates (Java -> Java Class) is used. This template file contains LF line endings, therefore the newly created file contains LF line endings on Windows machine instead of CRLF.

Template files use LF line endings and this is remembered for saving new files as described on http://wiki.netbeans.org/FaqEditorEOLs. It is not possible to globally configure what line endings the NetBeans should use.

Workaround: 
- open each template in the NetBeans editor
- slightly change the content of each template
- go to <user_home>/.netbeans/6.9/config/Templates/ and change file endings to CRLF 

This is a very annoying feature. Is it possible to use different templates for Windows and Linux NetBeans bundles? Or alter Editor logic when creating new files from template?
Comment 1 Peter Pis 2010-04-27 13:59:21 UTC
Reassigning for further evaluation.
Comment 2 David Simonek 2010-04-28 08:42:15 UTC
> This is a very annoying feature. Is it possible to use different templates for
> Windows and Linux NetBeans bundles? Or alter Editor logic when creating new
> files from template?

Having three versions of each template (Mac, Unix, Win) is not good idea IMHO, keeping things in sync is expensive and error-prone.

Mentioned wiki page http://wiki.netbeans.org/FaqEditorEOLs says among others: "For new files (constructed from templates) the editor uses platform-default line separator" which is apparently not true now.

So I would say bug in editor, editor should ensure that new files constructed from templates have platform-default line separator, as stated in wiki.
Comment 3 Vladimir Voskresensky 2010-04-28 20:00:21 UTC
(In reply to comment #2)
> 
> So I would say bug in editor, editor should ensure that new files constructed
> from templates have platform-default line separator, as stated in wiki.
This is not completely correct.
Makefiles and scripts created from template must not have CR on any platform, otherwise it can not work.
We do enforce LF as line separator in ShellKit and MakefileKit => make sure it is not broken
Comment 4 Vitezslav Stejskal 2010-05-03 14:33:52 UTC
The same happens in Nb 6.8. AFAIK the editor is not involved in files creation. The template file is simply copied over to the new location with some involvement of the file's associated loader and some free marker processing.

There are related issues concerning line endings filed for the editor - see issue #72515 and its duplicates. This however has nothing to do with the way how the IDE creates files.
Comment 5 Jaroslav Tulach 2010-05-03 17:32:39 UTC
Your guess is not correct. Editor is heavily involved in files creation. Look at org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler

I've just tried to create a Java file. The indentation engine is:
org.netbeans.modules.editor.SimpleIndentEngine
the writer is:
org.netbeans.editor.ext.FormatWriter

Moving back to editor. Fix your writer to honor platform new line style (and give Vladimir a way to prevent that for makefiles). Should some special hint be needed from the ScriptingCreateFromTemplateHandler to indicate creation of new file, propose it as part of your diff.
Comment 6 Vitezslav Stejskal 2010-05-04 11:39:06 UTC
(In reply to comment #5)
> Your guess is not correct. Editor is heavily involved in files creation. Look
> at org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler

Ah, thanks for the hint Jarda. I had no idea that IndentEngines are still used in the files creation process.
Comment 7 Vitezslav Stejskal 2010-05-04 12:31:04 UTC
The formatting of new files has never really worked. I know this is not an excuse, but since this is not a regression from 6.8 I'm lowering the priority and setting TM = Next. Fixing this is likely to require a substantial amount of work, which I would rather not attempt that close to code freeze.
Comment 8 David Strupl 2012-10-25 13:39:14 UTC
Bug prior to 7.0, not touched for the last 2 years --> P4.
Comment 9 Martin Balin 2016-07-07 07:29:29 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss