Bug 45352 Smart paste garbles indentation of commented code block
Copy this: // int abs(int i) { // //TODO: use Math.abs // if (i > 0) { // return i; // } else { // return -i; // } // } Pasting yields: // int abs(int i) { // //TODO: use Math.abs // if (i > 0) { // return i; // } else { // return -i; // } // }
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
if ("//".equals(s)) { 
						endOfWS= scanner.findNonWhitespaceForwardInAnyPartition(lineOffset + 2, lineOffset + r.getLength());
						lineOffset += 2;
					}
				}
				
				int wsLen= Math.max(endOfWS - lineOffset, 0);
				temp.replace(lineOffset, wsLen, indent);
			}
			
			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) == '{')