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.
TestCase: public void testGetOriginalForLineFromDifferentLineSet2 () throws Exception { content = "line 1\nline 2\n"; javax.swing.text.Document doc = support.openDocument (); Line.Set lineSet1 = support.getLineSet (); doc.insertString (6, "\nnew line", null); support.saveDocument (); Line.Set lineSet2 = support.getLineSet (); Line line = lineSet2.getCurrent(2); assertEquals ("line number is 2", 2, line.getLineNumber ()); assertGetOriginal ("original line number is 1", lineSet1, line, 1); assertGetOriginal ("original line number is 2", lineSet2, line, 2); doc.insertString (6, "\nnew line", null); assertEquals ("line number is 3", 3, line.getLineNumber ()); assertGetOriginal ("original line number is 1", lineSet1, line, 1); assertGetOriginal ("original line number is 2", lineSet2, line, 2); System.out.println(doc.getText(0, doc.getLength())); }
Created attachment 15776 [details] The fix that works on DocumentLine.Set but the default impl on Line.Set is not working yet. Still give it a try and review.
Hanzi, you should learn cvs diff -u! I think that the right solution is to share the WeakHashMap of lines between all Line.Sets created for the same CES. Review would be nice.
Hanzi your unit tests not only discovered the problem of nonshared lines between mutual LineSets, but also that the fallback implementation in Line.Set.getOriginalLineNumber has one bug. Good start with junit and do not be affraid to go on! #45014: Sharing the map of lines between all linesets for one cloneable editor support. All the unit tests were written by jjancura@netbeans.org /cvs/openide/src/org/openide/text/CloneableEditorSupport.java,v <-- CloneableEditorSupport.java new revision: 1.124; previous revision: 1.123 done Checking in src/org/openide/text/DocumentLine.java; /cvs/openide/src/org/openide/text/DocumentLine.java,v <-- DocumentLine.java new revision: 1.56; previous revision: 1.55 done Checking in src/org/openide/text/EditorSupportLineSet.java; /cvs/openide/src/org/openide/text/EditorSupportLineSet.java,v <-- EditorSupportLineSet.java new revision: 1.39; previous revision: 1.38 done Checking in src/org/openide/text/Line.java; /cvs/openide/src/org/openide/text/Line.java,v <-- Line.java new revision: 1.29; previous revision: 1.28 done Processing log script arguments... More commits to come... Checking in test/unit/src/org/openide/text/LineSetTest.java; /cvs/openide/test/unit/src/org/openide/text/LineSetTest.java,v <-- LineSetTest.java new revision: 1.3; previous revision: 1.2
Closed, too old