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
return;
		String[] legalLineDelimiters= document.getLegalLineDelimiters();
		String lineDelimiter= legalLineDelimiters[0];
		String indentation= getLineIndentation(document, command.offset);
		IRegion line= document.getLineInformationOfOffset(offset);
		String string= document.get(line.getOffset(), offset - line.getOffset());
		if (string.trim().length() != 0)
			indentation += String.valueOf('\t');
		command.text= getModifiedText(command.text, lineDelimiter, indentation);		
	}
	/*
	 * @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(IDocument, DocumentCommand)
	 */
	public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
		try {
			if (command.length != 0 || command.text == null)
				return;
			IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
				
			if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS) &&
				hasLineDelimiters(document, command.text))
			{
				javaStringIndentAfterNewLine(document, command);
			}
				
		} catch (BadLocationException e) {
		}
	}
}