Bug 45352 Smart paste garbles indentation of commented code block
Copy this: // int abs(int i) { // //TODO: use Math.abs // if (i > 0) { // return i; // } else { // return -i; // } // } Pasting yields: // int abs(int i) { // //TODO: use Math.abs // if (i > 0) { // return i; // } else { // return -i; // } // }
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
int refPos= indenter.findReferencePosition(offset);
			if (refPos == JavaHeuristicScanner.NOT_FOUND)
				return;
			IRegion region= document.getLineInformationOfOffset(refPos);
			int lineOffset= region.getOffset();
			
			
			int endOfWS= scanner.findNonWhitespaceForwardInAnyPartition(lineOffset, JavaHeuristicScanner.UNBOUND);
			if (endOfWS == JavaHeuristicScanner.NOT_FOUND)
				endOfWS= lineOffset;
			String baseIndent= document.get(lineOffset, endOfWS - lineOffset);
			if (refPos == JavaHeuristicScanner.NOT_FOUND)
				return;
			 
			region= document.getLineInformationOfOffset(offset);
			String notSelected= document.get(region.getOffset(), offset - region.getOffset());
			if (notSelected.trim().length() == 0) {
				command.length += notSelected.length();
				command.offset= region.getOffset();
			}
			
			
			String prefix= baseIndent + document.get(refPos, command.offset - refPos);
			Document temp= new Document(prefix + command.text);
			
			
			
			region= temp.getLineInformation(temp.getNumberOfLines() - 1);
			boolean eatAfterSpace= temp.get(region.getOffset(), region.getLength()).trim().length() == 0;
			String afterContent= new String();