Bug 47674 Formatting problem with paste
M5: - create class Bar with this code: public class Bar { void foo() { int i= 1; if (i == 2) { i= 1; } i= 2; } } - select full line "i= 2" and cut to clipboard - paste line inside if-statement Observe: the closing bracket is indented public class Bar { void foo() { int i= 1; if (i == 2) { i= 1; i= 2; } } }
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
			};