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
indent.append(' ');
					
				endOfWS= scanner.findNonWhitespaceForwardInAnyPartition(lineOffset, lineOffset + lineLength);
				if (endOfWS == JavaHeuristicScanner.NOT_FOUND)
					endOfWS= lineOffset + lineLength;
				
				int wsLen= Math.max(endOfWS - lineOffset, 0);
				temp.replace(lineOffset, wsLen, indent.toString());
			}
			
			temp.setDocumentPartitioner(IJavaPartitions.JAVA_PARTITIONING, null);
			partitioner.disconnect();
			command.text= temp.get(prefix.length(), temp.getLength() - prefix.length() - afterContent.length());
			
		} catch (BadLocationException e) {
			JavaPlugin.log(e);
		} catch (BadPartitioningException e) {
			JavaPlugin.log(e);
		}
	}
	private boolean isLineDelimiter(IDocument document, String text) {
		String[] delimiters= document.getLegalLineDelimiters();
		if (delimiters != null)
			return TextUtilities.equals(delimiters, text) > -1;
		return false;
	}
	private void smartIndentAfterBlockDelimiter(IDocument document, DocumentCommand command) {
		if (command.text.charAt(0) == '}')
			smartIndentAfterClosingBracket(document, command);
		else if (command.text.charAt(0) == '{')