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
buf.append(getLineDelimiter(d));
				String reference= indenter.getReferenceIndentation(c.offset); 
				buf.append(reference == null ? "" : reference); 
				buf.append('}');
			}
			c.text= buf.toString();
		} catch (BadLocationException e) {
			JavaPlugin.log(e);
		}
	}
	/**
	 * Computes an insert position for an opening brace if <code>offset</code> maps to a position in
	 * <code>document</code> with a expression in parenthesis that will take a block after the closing parenthesis.
	 * 
	 * @param document the document being modified
	 * @param offset the offset of the caret position, relative to the line start.
	 * @param partitioning the document partitioning
	 * @param max the max position
	 * @return an insert position relative to the line start if <code>line</code> contains a parenthesized expression that can be followed by a block, -1 otherwise
	 */
	private static int computeAnonymousPosition(IDocument document, int offset, String partitioning,  int max) {
		
		
		
		
		JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
		int pos= offset;
		int length= max;
		int scanTo= scanner.scanForward(pos, length, '}');