aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-03-20 04:41:57 (EDT)
committerzzhongwei2013-03-20 04:41:57 (EDT)
commite267b0b9f680b15b5ba87d0023f83a14a601f51d (patch)
tree527d86f26995fe19c3ab7966b1a2d2a37d24cff4
parentff5d379a457b702d879c2497ecb2c2eaa4a3cfe7 (diff)
downloadorg.eclipse.pdt-e267b0b9f680b15b5ba87d0023f83a14a601f51d.zip
org.eclipse.pdt-e267b0b9f680b15b5ba87d0023f83a14a601f51d.tar.gz
org.eclipse.pdt-e267b0b9f680b15b5ba87d0023f83a14a601f51d.tar.bz2
397498: Indent using spaces always uses tab size
https://bugs.eclipse.org/bugs/show_bug.cgi?id=397498
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/autoEdit/TabAutoEditStrategy.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/autoEdit/TabAutoEditStrategy.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/autoEdit/TabAutoEditStrategy.java
index 26b2c25..5080d3c 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/autoEdit/TabAutoEditStrategy.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/autoEdit/TabAutoEditStrategy.java
@@ -255,8 +255,29 @@ public class TabAutoEditStrategy implements IAutoEditStrategy {
.getIndentationChar(document);
if (indentChar == ' ') {
+ // determine where in line this command begins
+ int lineOffset = -1;
+ try {
+ IRegion lineInfo = document
+ .getLineInformationOfOffset(command.offset);
+ lineOffset = command.offset - lineInfo.getOffset();
+ } catch (BadLocationException e) {
+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
+ }
+
int indentSize = formatterCommonPrferences
.getIndentationSize(document);
+
+ if (lineOffset > 0) {
+ lineOffset %= indentSize;
+ indentSize -= lineOffset;
+ }
+
+ if (indentSize == 0) {
+ indentSize = formatterCommonPrferences
+ .getIndentationSize(document);
+ }
+
command.text += getIndentationString(indentSize);
} else {
command.text += "\t"; //$NON-NLS-1$