Bug 50194 Indenting Java breaks comments
When correcting indentation (ctrl-I in my configuration), java comments are not properly preserved. My original code [1] is 'indented' to code [2], which is unexpected and syntactically incorrect. thanks PhF .. [1] try{ /* for(int i=0; i<8; i++){ System.out.println("something");} */ somethingElse(); .. [2] try{ /* */ for(int i=0; i<8; i++){ System.out.println("something");} */ somethingElse();
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocAutoIndentStrategy.java
document.replace(c.offset, length, null);
					c.doit= false;
					c.length= 0;
					return;
				}
			
			} else if (document.getChar(c.offset - 1) == '*' && jdocExtractLinePrefix(document, line).length() - 1 >= c.offset - lineOffset) {
				lineDelimiter= document.getLineDelimiter(line - 1);
				String prefix= jdocExtractLinePrefix(document, line);
				int length= (lineDelimiter != null ? lineDelimiter.length() : 0) + prefix.length();
				document.replace(c.offset - length + 1, length, null);
				c.doit= false;
				c.offset -= length - 1;
				c.length= 0;
				return;
			} else {
				document.replace(c.offset, c.length, null);
				c.doit= false;
				c.length= 0;
			}
		} catch (BadLocationException e) {
			JavaPlugin.log(e);
		}
				
		try {
			int line= document.getLineOfOffset(c.offset);
			int lineOffset= document.getLineOffset(line);
			String prefix= jdocExtractLinePrefix(document, line);
			boolean always= c.offset > lineOffset && c.offset <= lineOffset + prefix.length();
			int[] caretOffset= {c.offset};