Index: JavaParserGlue.java =================================================================== RCS file: /cvs/java/src/org/netbeans/modules/java/JavaParserGlue.java,v retrieving revision 1.28 diff -c -r1.28 JavaParserGlue.java *** JavaParserGlue.java 8 Nov 2001 17:02:53 -0000 1.28 --- JavaParserGlue.java 27 Nov 2001 11:16:25 -0000 *************** *** 683,689 **** for (int i = 0; i < children.length; i++) { childElement = sourceToText(children[i]); if (childElement.getStartOffset() <= offset && ! childElement.getEndOffset() >= offset) { return i; } } --- 683,689 ---- for (int i = 0; i < children.length; i++) { childElement = sourceToText(children[i]); if (childElement.getStartOffset() <= offset && ! childElement.getEndOffset() > offset) { return i; } } Index: codegen/CodeGenerator.java =================================================================== RCS file: /cvs/java/src/org/netbeans/modules/java/codegen/CodeGenerator.java,v retrieving revision 1.6 diff -c -r1.6 CodeGenerator.java *** codegen/CodeGenerator.java 10 Oct 2001 08:56:25 -0000 1.6 --- codegen/CodeGenerator.java 27 Nov 2001 11:16:25 -0000 *************** *** 263,269 **** // Nonwhitespace before the insertion point, only whitespace after // retain only indentation boolean includingNewline = emptyBefore; ! if (doc.getLength() > lineEnd + 1) { if (emptyBefore) { javax.swing.text.Element nextLine = rootElement.getElement(myLineIndex + 1); String nextContents = doc.getText(nextLine.getStartOffset(), --- 263,269 ---- // Nonwhitespace before the insertion point, only whitespace after // retain only indentation boolean includingNewline = emptyBefore; ! if (doc.getLength() >= lineEnd) { if (emptyBefore) { javax.swing.text.Element nextLine = rootElement.getElement(myLineIndex + 1); String nextContents = doc.getText(nextLine.getStartOffset(), *************** *** 277,300 **** myLineIndex++; } } ! if (doc.getLength() == lineEnd) { // special case ! if (emptyBefore) { ! formatted = formatText(doc, lineEnd, "\n\n"); // NOI18N myLineIndex += 2; } else { ! formatted = formatText(doc, lineEnd, "\n"); // NOI18N myLineIndex++; } ! doc.insertString(lineEnd, formatted, null); ! newBlockOffset = lineEnd + formatted.length(); myLineIndex += emptyBefore ? 2 : 1; } else { ! formatted = formatText(doc, lineEnd + 1, "\n"); // NOI18N if (!includingNewline) formatted = formatted.substring(formatted.indexOf('\n') + 1); ! doc.insertString(lineEnd + 1, formatted, null); ! newBlockOffset = lineEnd + 1 + formatted.length(); myLineIndex++; doc.insertString(newBlockOffset, formatText( doc, newBlockOffset, "\n"), null // NOI18N --- 277,300 ---- myLineIndex++; } } ! if (doc.getLength() < lineEnd) { // special case ! if (emptyBefore && includingNewline) { ! formatted = formatText(doc, lineEnd-1, "\n\n"); // NOI18N myLineIndex += 2; } else { ! formatted = formatText(doc, lineEnd-1, "\n"); // NOI18N myLineIndex++; } ! doc.insertString(lineEnd-1, formatted, null); ! newBlockOffset = lineEnd-1 + formatted.length(); myLineIndex += emptyBefore ? 2 : 1; } else { ! formatted = formatText(doc, lineEnd, "\n"); // NOI18N if (!includingNewline) formatted = formatted.substring(formatted.indexOf('\n') + 1); ! doc.insertString(lineEnd, formatted, null); ! newBlockOffset = lineEnd + formatted.length(); myLineIndex++; doc.insertString(newBlockOffset, formatText( doc, newBlockOffset, "\n"), null // NOI18N *************** *** 433,441 **** javax.swing.text.Element line = lineRoot.getElement(lineIndex); p1 = line.getStartOffset(); p2 = line.getEndOffset(); - if (doc.getLength() > p2) { - p2++; - } try { if (doc.getText(p1, p2 - p1).trim().length() != 0) return; --- 433,438 ---- *************** *** 450,458 **** if ("".equals( doc.getText(p1 = line.getStartOffset(), (p2 = line.getEndOffset()) - line.getStartOffset()).trim())) { - if (doc.getLength() > p2) { - p2++; - } doc.remove(p1, p2 - p1); } else if (lineIndex > 0) { // try the prev line: --- 447,452 ---- *************** *** 460,468 **** if ("".equals( doc.getText(p1 = line.getStartOffset(), (p2 = line.getEndOffset()) - line.getStartOffset()).trim())) { - if (doc.getLength() > p2) { - p2++; - } doc.remove(p1, p2 - p1); } } --- 454,459 ---- Index: imptool/ImpDataSource.java =================================================================== RCS file: /cvs/java/src/org/netbeans/modules/java/imptool/ImpDataSource.java,v retrieving revision 1.9 diff -c -r1.9 ImpDataSource.java *** imptool/ImpDataSource.java 19 Sep 2001 08:11:44 -0000 1.9 --- imptool/ImpDataSource.java 27 Nov 2001 11:16:25 -0000 *************** *** 537,543 **** if (sourceEditor!=null && javaEditor!=null) { javax.swing.text.Element textEl=sourceEditor.sourceToText(el); int start=textEl.getStartOffset(); ! int end=textEl.getEndOffset(); PositionBounds bounds; if (!textEl.isLeaf()) { --- 537,543 ---- if (sourceEditor!=null && javaEditor!=null) { javax.swing.text.Element textEl=sourceEditor.sourceToText(el); int start=textEl.getStartOffset(); ! int end=textEl.getEndOffset()-1; PositionBounds bounds; if (!textEl.isLeaf()) {