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
/**
	 * Returns whether the text ends with one of the given search strings.
	 */
	private boolean hasLineDelimiters(IDocument document, String text) throws BadLocationException {
		String[] delimiters= document.getLegalLineDelimiters();
		
		for (int i= 0; i < delimiters.length; i++)
			if (text.indexOf(delimiters[i]) != -1)
				return true;
		
		return false;
	}
	
	private String getLineIndentation(IDocument document, int offset) throws BadLocationException {
		
		int adjustedOffset= (offset == document.getLength() ? offset  - 1 : offset);
		IRegion line= document.getLineInformationOfOffset(adjustedOffset);
		int start= line.getOffset();
					
		
		int end= findEndOfWhiteSpace(document, start, offset);
		
		return document.get(start, end - start);
	}