1
1
package csep .ui .autoedit ;
2
2
3
+ import org .eclipse .core .runtime .Platform ;
3
4
import org .eclipse .jface .text .BadLocationException ;
4
5
import org .eclipse .jface .text .DefaultIndentLineAutoEditStrategy ;
5
6
import org .eclipse .jface .text .DocumentCommand ;
12
13
public class IndentLineAutoEditStrategy extends
13
14
DefaultIndentLineAutoEditStrategy {
14
15
16
+ private static final String EDITORS_QUALIFIER = "org.eclipse.ui.editors" ;
17
+
15
18
/**
16
19
* Start an indented block after certain lines
17
20
*/
@@ -31,9 +34,20 @@ protected void indentBlock(IDocument d, DocumentCommand c) {
31
34
int p = (c .offset == d .getLength () ? c .offset - 1 : c .offset );
32
35
IRegion info = d .getLineInformationOfOffset (p );
33
36
String line = d .get (info .getOffset (), info .getLength ());
34
- if (Helper .isBlockContainer (line ))
35
- // TODO: get actual indentation string
36
- c .text += "\t " ;
37
+ if (Helper .isBlockContainer (line )) {
38
+ if (Helper .isBlockContainer (line )) {
39
+ boolean spacesForTabs = Platform .getPreferencesService ().getBoolean (EDITORS_QUALIFIER ,
40
+ "spacesForTabs" , false , null );
41
+ if (spacesForTabs ) {
42
+ int tabWidth = Platform .getPreferencesService ().getInt (EDITORS_QUALIFIER , "tabWidth" , 4 , null );
43
+ for (int i = 0 ; i < tabWidth ; i ++) {
44
+ c .text += " " ;
45
+ }
46
+ } else {
47
+ c .text += "\t " ;
48
+ }
49
+ }
50
+ }
37
51
}
38
52
catch (BadLocationException e ) {
39
53
// do nothing
0 commit comments