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
if (eatAfterSpace) {
				int selectionEnd= command.offset + command.length;
				region= document.getLineInformationOfOffset(selectionEnd);
				endOfWS= scanner.findNonWhitespaceForwardInAnyPartition(selectionEnd, region.getOffset() + region.getLength());
				if (endOfWS != JavaHeuristicScanner.NOT_FOUND) {
					int token= scanner.nextToken(selectionEnd, region.getOffset() + region.getLength());
					if (token != Symbols.TokenEOF && token != Symbols.TokenCASE) { 
						command.length += endOfWS - selectionEnd;
						afterContent= document.get(endOfWS, scanner.getPosition() - endOfWS);
					}
				} else {
					
					command.length += region.getOffset() + region.getLength() - selectionEnd;
					afterContent= "x"; 
				}
			}
			
			
			temp.replace(temp.getLength(), 0, afterContent);
			
			scanner= new JavaHeuristicScanner(temp);
			indenter= new JavaIndenter(temp, scanner);
			String[] types= new String[] {
									   IJavaPartitions.JAVA_DOC,
									   		IJavaPartitions.JAVA_MULTI_LINE_COMMENT,
									   		IJavaPartitions.JAVA_SINGLE_LINE_COMMENT,
									   		IJavaPartitions.JAVA_STRING,
									   		IJavaPartitions.JAVA_CHARACTER,
									   		IDocument.DEFAULT_CONTENT_TYPE
			};