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 73929 - LineSeparatorConversion has incorrect default ('\n')
Summary: LineSeparatorConversion has incorrect default ('\n')
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 4.x
Hardware: All All
: P4 blocker with 1 vote (vote)
Assignee: Jan Pokorsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-23 16:39 UTC by cahrens
Modified: 2007-11-05 13:44 UTC (History)
0 users

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 cahrens 2006-03-23 16:39:56 UTC
If you are reading from a File that is either empty or has a single line of text
(with no line separator), org.netbeans.editor.LineSeparatorConversion will
return a default of '\n' regardless of platform.  It should return the
platform-specific line separator (Analyzer.getPlatformLS()).  

This causes a bug in our product when a user creates a blank file, types new
text into it, and then saves.  The file will always have '\n' line separators.  

Here is the change I made in LineSeparatorConversion's getInitialSeparator method:

default:
     // CLA changed default to be platform-specific default
     // separator = "\n"; // default // NOI18N
     separator = (String)Analyzer.getPlatformLS();
     break;
}

This method is called as part of Analyzer's initialRead and overwrites the
previously set (correct) default line separator value:

if (testLS) {
   doc.putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP,
                
((LineSeparatorConversion.InitialSeparatorReader)reader).getInitialSeparator());
Comment 1 Vitezslav Stejskal 2007-04-16 04:00:26 UTC
Should be easy to fix.
Comment 2 Jan Pokorsky 2007-08-13 18:12:50 UTC
fixed in

/cvs/editor/libsrc/org/netbeans/editor/LineSeparatorConversion.java
new revision: 1.7; previous revision: 1.6