Index: libsrc/org/netbeans/editor/BaseDocument.java =================================================================== RCS file: /cvs/editor/libsrc/org/netbeans/editor/BaseDocument.java,v retrieving revision 1.86 diff -c -r1.86 BaseDocument.java *** libsrc/org/netbeans/editor/BaseDocument.java 12 Feb 2002 15:10:02 -0000 1.86 --- libsrc/org/netbeans/editor/BaseDocument.java 12 Jun 2002 16:14:25 -0000 *************** *** 465,473 **** /** Length of document. * @return number of characters >= 0 */ ! public final int getLength() { return op.length(); } /** Create the mark for the given position * and store it in the list. The position can --- 465,474 ---- /** Length of document. * @return number of characters >= 0 */ ! /* inherit from AbstractDocument public final int getLength() { return op.length(); } + */ /** Create the mark for the given position * and store it in the list. The position can *************** *** 590,596 **** throw new BadLocationException("Wrong remove position", offset); // NOI18N } if (offset + len > docLen) { ! throw new BadLocationException("End offset of removed text is too big", offset + len); // NOI18N } preRemoveCheck(offset, len); --- 591,600 ---- throw new BadLocationException("Wrong remove position", offset); // NOI18N } if (offset + len > docLen) { ! throw new BadLocationException("End offset of removed text " ! + (offset + len) + " > getLength()=" + docLen, ! offset + len ! ); // NOI18N } preRemoveCheck(offset, len); *************** *** 1146,1152 **** + Utilities.debugDocument(BaseDocument.this) + "." // NOI18N ); */ ! return getElement(Utilities.getRowCount(BaseDocument.this) - 1); // last line } --- 1150,1156 ---- + Utilities.debugDocument(BaseDocument.this) + "." // NOI18N ); */ ! return null; // getElement(Utilities.getRowCount(BaseDocument.this) - 1); // last line } Index: libsrc/org/netbeans/editor/DocCache.java =================================================================== RCS file: /cvs/editor/libsrc/org/netbeans/editor/DocCache.java,v retrieving revision 1.24 diff -c -r1.24 DocCache.java *** libsrc/org/netbeans/editor/DocCache.java 20 Dec 2000 16:15:08 -0000 1.24 --- libsrc/org/netbeans/editor/DocCache.java 12 Jun 2002 16:14:26 -0000 *************** *** 500,505 **** --- 500,515 ---- throwPosException(pos); } if (pos + len > getDocLenImpl()) { + if (pos + len == getDocLenImpl() + 1) { // fix of #17061 - append '\n' + if (len == 0) { + return; + } + len--; + ret[offset + len] = '\n'; + read(pos, ret, offset, len, frag); + return; + } // end of fix #17061 + throwPosException(pos + len); } if (directMode) { Index: libsrc/org/netbeans/editor/DocOp.java =================================================================== RCS file: /cvs/editor/libsrc/org/netbeans/editor/DocOp.java,v retrieving revision 1.15 diff -c -r1.15 DocOp.java *** libsrc/org/netbeans/editor/DocOp.java 17 Jan 2002 18:50:35 -0000 1.15 --- libsrc/org/netbeans/editor/DocOp.java 12 Jun 2002 16:14:27 -0000 *************** *** 158,163 **** --- 158,164 ---- DocOp() { marks = new DocMarks(); marks.startMark.setOp(this); + marks.update(0, 0, 1, 1); cacheSupport = new MemCacheSupport(); cache = new DocCache(cacheSupport, 2048, true); // !!! *************** *** 215,223 **** public synchronized Position createPosition(int offset) throws BadLocationException { boolean insertAfter = (offset == 0); // support AbstractDocument keep marks at position 0 behavior ! if (offset == docLen + 1) { // support AbstractDocument's content initial "\n" behavior offset = docLen; } return new BasePosition(this, offset, insertAfter ? Position.Bias.Backward : Position.Bias.Forward); --- 216,225 ---- public synchronized Position createPosition(int offset) throws BadLocationException { boolean insertAfter = (offset == 0); // support AbstractDocument keep marks at position 0 behavior ! /* if (offset == docLen + 1) { // support AbstractDocument's content initial "\n" behavior offset = docLen; } + */ return new BasePosition(this, offset, insertAfter ? Position.Bias.Backward : Position.Bias.Forward); *************** *** 229,235 **** } public synchronized int length() { ! return docLen; } public String getString(int where, int len) throws BadLocationException { --- 231,237 ---- } public synchronized int length() { ! return docLen + 1; } public String getString(int where, int len) throws BadLocationException { *************** *** 300,306 **** */ synchronized void insertMark(Mark mark, int offset) throws BadLocationException, InvalidMarkException { ! if (offset < 0 || offset > docLen) { throw new BadLocationException(WRONG_POSITION + offset + DOC_LEN + docLen, offset); } --- 302,308 ---- */ synchronized void insertMark(Mark mark, int offset) throws BadLocationException, InvalidMarkException { ! if (offset < 0 || offset > docLen + 1) { throw new BadLocationException(WRONG_POSITION + offset + DOC_LEN + docLen, offset); } *************** *** 355,361 **** /** Moves the mark to different position */ synchronized void moveMark(Mark mark, int newPos) throws BadLocationException, InvalidMarkException { ! if (newPos < 0 || newPos > docLen) { throw new BadLocationException(WRONG_POSITION + newPos + DOC_LEN + docLen, newPos); } mark.remove(); --- 357,363 ---- /** Moves the mark to different position */ synchronized void moveMark(Mark mark, int newPos) throws BadLocationException, InvalidMarkException { ! if (newPos < 0 || newPos > docLen + 1) { throw new BadLocationException(WRONG_POSITION + newPos + DOC_LEN + docLen, newPos); } mark.remove(); *************** *** 402,408 **** synchronized int getEOLNL(int pos) throws BadLocationException { int eol = getEOLImpl(pos); if (eol < docLen) { ! return eol++; } return eol; } --- 404,410 ---- synchronized int getEOLNL(int pos) throws BadLocationException { int eol = getEOLImpl(pos); if (eol < docLen) { ! return ++eol; } return eol; } *************** *** 521,527 **** if (pos == 0) { return 0; } ! throw new BadLocationException(WRONG_POSITION + pos + DOC_LEN + length(), pos); } // search cache --- 523,529 ---- if (pos == 0) { return 0; } ! throw new BadLocationException(WRONG_POSITION + pos + DOC_LEN + (length() - 1), pos); } // search cache *************** *** 543,549 **** private int getEOLImpl(int pos) throws BadLocationException { if (pos < 0) { ! throw new BadLocationException(WRONG_POSITION + pos + DOC_LEN + length(), pos); } // search cache --- 545,551 ---- private int getEOLImpl(int pos) throws BadLocationException { if (pos < 0) { ! throw new BadLocationException(WRONG_POSITION + pos + DOC_LEN + (length() - 1), pos); } // search cache *************** *** 589,596 **** } private int getLineImpl(int pos) throws BadLocationException { if (pos < 0 || pos > docLen) { ! throw new BadLocationException(WRONG_POSITION + pos + DOC_LEN + length(), pos); } // search cache --- 591,602 ---- } private int getLineImpl(int pos) throws BadLocationException { + if (pos == docLen + 1) { + return getLineImpl(docLen) + 1; + } + if (pos < 0 || pos > docLen) { ! throw new BadLocationException(WRONG_POSITION + pos + DOC_LEN + (length() - 1), pos); } // search cache *************** *** 773,779 **** } } if (!found) { ! dist = length() - leftMarkPos; } // test for too small distance if (dist < MIN_MARK_DISTANCE && found) { --- 779,785 ---- } } if (!found) { ! dist = (length() - 1) - leftMarkPos; } // test for too small distance if (dist < MIN_MARK_DISTANCE && found) {