Skip to content

Commit

Permalink
Fix xml indetation with indent_zie != 1
Browse files Browse the repository at this point in the history
  • Loading branch information
victornoel committed Jun 9, 2018
1 parent fd9d46f commit 02b4e04
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.editorconfig.core.ConfigProperty;
import org.eclipse.editorconfig.core.ConfigPropertyType;
import org.eclipse.editorconfig.core.ConfigPropertyVisitor;
import org.eclipse.editorconfig.core.EditorFileConfig;
import org.eclipse.editorconfig.core.EndOfLineOption;
Expand Down Expand Up @@ -51,13 +52,17 @@ public void visitIndentStyle(final ConfigProperty<IndentStyleOption> property) {
@Override
public void visitIndentSize(final ConfigProperty<Integer> property) {
final String indentSizeString = property.getValue().toString();
setPreference("org.eclipse.wst.xml.core", "indentationSize", indentSizeString);
setPreference("org.eclipse.jdt.core", "org.eclipse.jdt.core.formatter.indentation.size", indentSizeString);
// this represents the number of tabs, not their width
setPreference("org.eclipse.wst.xml.core", "indentationSize",
config.getConfigProperty(ConfigPropertyType.INDENT_STYLE.getName()).getValue().equals(IndentStyleOption.SPACE)
? indentSizeString
: "1");
}

@Override
public void visitTabWidth(final ConfigProperty<Integer> property) {
final String tabWidth = property.getValue().toString();
// xml editor will follow this
setPreference("org.eclipse.ui.editors", "tabWidth", tabWidth);
setPreference("org.eclipse.jdt.core", "org.eclipse.jdt.core.formatter.tabulation.size", tabWidth);
setPreference("org.eclipse.ant.ui", "formatter_tab_size", tabWidth);
Expand Down

0 comments on commit 02b4e04

Please sign in to comment.