commit | 03687074a3cbd618dd7371b142767437c5b12145 | [log] [tgz] |
---|---|---|
author | apanchenk <apanchenk> | Wed May 13 09:15:14 2009 +0000 |
committer | apanchenk <apanchenk> | Wed May 13 09:15:14 2009 +0000 |
tree | 4ea180770682492bc6700e3ad95240414423590e | |
parent | 629526c25c5d71ab3717fdd747b29042d504316b [diff] |
replace sequences of spaces+tabs with single space
diff --git a/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterContext.java b/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterContext.java index ca5b2aa..fc3a7d9 100644 --- a/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterContext.java +++ b/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterContext.java
@@ -33,6 +33,7 @@ private int indent; private boolean indenting = true; + private boolean comment = false; private boolean wrapping = false; private int blankLines = 0; private final List path = new ArrayList(); @@ -90,6 +91,14 @@ this.indenting = value; } + public boolean isComment() { + return comment; + } + + public void setComment(boolean value) { + this.comment = value; + } + public int getBlankLines() { return blankLines; }
diff --git a/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterWriter.java b/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterWriter.java index 57afe91..f4dea0c 100644 --- a/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterWriter.java +++ b/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterWriter.java
@@ -254,8 +254,12 @@ writer.append(ch); } } else { - if (preserveSpaces || !context.isIndenting() || ch != ' ' - || writer.charAt(writer.length() - 1) != ' ') { + if (!preserveSpaces && context.isIndenting() + && !context.isComment() && FormatterUtils.isSpace(ch)) { + if (writer.charAt(writer.length() - 1) != ' ') { + writer.append(' '); + } + } else { writer.append(ch); } }
diff --git a/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/IFormatterContext.java b/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/IFormatterContext.java index 6797379..3e1a9b5 100644 --- a/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/IFormatterContext.java +++ b/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/IFormatterContext.java
@@ -25,7 +25,11 @@ boolean isIndenting(); - void setIndenting(boolean valud); + void setIndenting(boolean value); + + boolean isComment(); + + void setComment(boolean value); int getBlankLines();