Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions csep.ui/src/csep/ui/autoedit/IndentLineAutoEditStrategy.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package csep.ui.autoedit;

import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
import org.eclipse.jface.text.DocumentCommand;
Expand All @@ -12,6 +13,8 @@
public class IndentLineAutoEditStrategy extends
DefaultIndentLineAutoEditStrategy {

private static final String EDITORS_QUALIFIER = "org.eclipse.ui.editors";

/**
* Start an indented block after certain lines
*/
Expand All @@ -31,9 +34,20 @@ protected void indentBlock(IDocument d, DocumentCommand c) {
int p = (c.offset == d.getLength() ? c.offset - 1 : c.offset);
IRegion info= d.getLineInformationOfOffset(p);
String line = d.get(info.getOffset(), info.getLength());
if (Helper.isBlockContainer(line))
// TODO: get actual indentation string
c.text += "\t";
if (Helper.isBlockContainer(line)) {
if (Helper.isBlockContainer(line)) {
boolean spacesForTabs = Platform.getPreferencesService().getBoolean(EDITORS_QUALIFIER,
"spacesForTabs", false, null);
if (spacesForTabs) {
int tabWidth = Platform.getPreferencesService().getInt(EDITORS_QUALIFIER, "tabWidth", 4, null);
for (int i = 0; i < tabWidth; i++) {
c.text += " ";
}
} else {
c.text += "\t";
}
}
}
}
catch (BadLocationException e) {
// do nothing
Expand Down