diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormattingStrategy.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormattingStrategy.java
index 5671dfe..14d1115 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormattingStrategy.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormattingStrategy.java
@@ -25,6 +25,7 @@
 import org.eclipse.jface.text.formatter.FormattingContextProperties;
 import org.eclipse.jface.text.formatter.IFormattingContext;
 
+import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jdt.core.ToolFactory;
 import org.eclipse.jdt.core.compiler.IScanner;
 import org.eclipse.jdt.core.compiler.ITerminalSymbols;
@@ -88,7 +89,7 @@
 				int sourceLength= partitionOffset + position.getLength();
 				String source= document.get(sourceOffset, sourceLength);
 				CodeFormatter commentFormatter= ToolFactory.createCodeFormatter(preferences);
-				int indentationLevel= inferIndentationLevel(source.substring(0, partitionOffset), getTabSize(preferences));
+				int indentationLevel= inferIndentationLevel(source.substring(0, partitionOffset), getTabSize(preferences), getIndentSize(preferences));
 				edit= commentFormatter.format(getKindForPartitionType(position.getType()), source, partitionOffset, position.getLength(), indentationLevel, TextUtilities.getDefaultLineDelimiter(document));
 
 				// move edit offset to match document
@@ -153,19 +154,19 @@
 	 *
 	 * @param reference the reference indentation
 	 * @param tabSize the tab size
+	 * @param indentSize the indent size in space equivalents
 	 * @return the inferred indentation level
 	 * @since 3.1
 	 */
-	private int inferIndentationLevel(String reference, int tabSize) {
+	private int inferIndentationLevel(String reference, int tabSize, int indentSize) {
 		StringBuffer expanded= expandTabs(reference, tabSize);
 
 		int referenceWidth= expanded.length();
 		if (tabSize == 0)
 			return referenceWidth;
 
-		int spaceWidth= 1;
-		int level= referenceWidth / (tabSize * spaceWidth);
-		if (referenceWidth % (tabSize * spaceWidth) > 0)
+		int level= referenceWidth / indentSize;
+		if (referenceWidth % indentSize > 0)
 			level++;
 		return level;
 	}
@@ -198,23 +199,60 @@
 	}
 
 	/**
-	 * Returns the value of {@link DefaultCodeFormatterConstants#FORMATTER_TAB_SIZE}
-	 * from the given preferences.
+	 * Returns the visual tab size.
 	 *
 	 * @param preferences the preferences
-	 * @return the value of {@link DefaultCodeFormatterConstants#FORMATTER_TAB_SIZE}
-	 *         from the given preferences
+	 * @return the visual tab size
 	 * @since 3.1
 	 */
 	private static int getTabSize(Map preferences) {
-		if (preferences.containsKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE))
+		/*
+		 * If the tab-char is SPACE, FORMATTER_INDENTATION_SIZE is not used
+		 * by the core formatter.
+		 * We piggy back the visual tab length setting in that preference in
+		 * that case. See CodeFormatterUtil.
+		 */
+		String key;
+		if (JavaCore.SPACE.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
+			key= DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
+		else
+			key= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
+
+		if (preferences.containsKey(key))
 			try {
-				return Integer.parseInt((String) preferences.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE));
+				return Integer.parseInt((String) preferences.get(key));
 			} catch (NumberFormatException e) {
 				// use default
 			}
 		return 4;
 	}
+	
+	/**
+	 * Returns the indentation size in space equivalents.
+	 *
+	 * @param preferences the preferences
+	 * @return the indentation size in space equivalents
+	 * @since 3.3
+	 */
+	private static int getIndentSize(Map preferences) {
+		/*
+		 * FORMATTER_INDENTATION_SIZE is only used if FORMATTER_TAB_CHAR is MIXED. Otherwise, the
+		 * indentation size is in FORMATTER_TAB_CHAR. See CodeFormatterUtil.
+		 */
+		String key;
+		if (DefaultCodeFormatterConstants.MIXED.equals(preferences.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
+			key= DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
+		else
+			key= DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR;
+		
+		if (preferences.containsKey(key))
+			try {
+				return Integer.parseInt((String) preferences.get(key));
+			} catch (NumberFormatException e) {
+				// use default
+			}
+			return 4;
+	}
 
 	/**
 	 * Returns the end offset for the document's header.
