Bug 34205 Wrap string produces incorrect code
Balance string is turned off, wrap string on. User is entering a list of string constants, e.g., public static final String[] KEYWORDS = new String[] { "a", "b", //... }; To make data entry go faster, user copies to clipboard the "continuation" of each line, e.g., the characters: ", " Now, user types, "c and pastes the continuation, expecting to see: "c", " Instead, the generated code is: "c"," + " " I can't think of a satisfactory explanation for this result; it seems to be a plain old bug. But the correct behavior would be to recognize that the leading " in the pasted text completes a string on the same line and the trailing " starts a new string on a new line, so no string is being continued and there is no need for a continuation.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaStringAutoIndentStrategy.java
private String getModifiedText(String string, String lineDelimiter, String indentation) throws BadLocationException {		
		String indentedLine= lineDelimiter + indentation;
		IDocument document= new Document(string);			
		StringBuffer buffer= new StringBuffer();
		IRegion line= document.getLineInformation(0);
		buffer.append(document.get(line.getOffset(), line.getLength()));
		buffer.append("\" +"); 
		int lineCount= document.getNumberOfLines();
		for (int i= 1; i < lineCount - 1; i++) {
			line= document.getLineInformation(i);
			buffer.append(indentedLine);
			buffer.append('\"');
			buffer.append(document.get(line.getOffset(), line.getLength()));
			buffer.append("\" +"); 
		}
		
		line= document.getLineInformation(lineCount - 1);
		buffer.append(indentedLine);
		buffer.append('\"');
		buffer.append(document.get(line.getOffset(), line.getLength()));
		return buffer.toString();
	}
	private void javaStringIndentAfterNewLine(IDocument document, DocumentCommand command) throws BadLocationException {
		ITypedRegion partition= document.getPartition(command.offset);
		int offset= partition.getOffset();
		int length= partition.getLength();
		if (command.offset == offset)
			return;
		
		if (command.offset == offset + length && document.getChar(offset + length - 1) == '\"')