@@ -44,22 +44,29 @@ public class CSharpFormattingStrategy : DefaultFormattingStrategy
4444 #region Smart Indentation
4545 public override void IndentLine ( ITextEditor editor , IDocumentLine line )
4646 {
47- var document = editor . Document ;
48- var engine = CreateIndentEngine ( document , editor . ToEditorOptions ( ) ) ;
49- IndentSingleLine ( engine , document , line ) ;
47+ int lineNr = line . LineNumber ;
48+ DocumentAccessor acc = new DocumentAccessor ( editor . Document , lineNr , lineNr ) ;
49+
50+ CSharpIndentationStrategy indentStrategy = new CSharpIndentationStrategy ( ) ;
51+ indentStrategy . IndentationString = editor . Options . IndentationString ;
52+ indentStrategy . Indent ( acc , false ) ;
53+
54+ string t = acc . Text ;
55+ if ( t . Length == 0 ) {
56+ // use AutoIndentation for new lines in comments / verbatim strings.
57+ base . IndentLine ( editor , line ) ;
58+ }
5059 }
5160
5261 public override void IndentLines ( ITextEditor editor , int beginLine , int endLine )
5362 {
54- var document = editor . Document ;
55- var engine = CreateIndentEngine ( document , editor . ToEditorOptions ( ) ) ;
56- int currentLine = beginLine ;
57- do {
58- var line = document . GetLineByNumber ( currentLine ) ;
59- IndentSingleLine ( engine , document , line ) ;
60- } while ( ++ currentLine <= endLine ) ;
63+ DocumentAccessor acc = new DocumentAccessor ( editor . Document , beginLine , endLine ) ;
64+ CSharpIndentationStrategy indentStrategy = new CSharpIndentationStrategy ( ) ;
65+ indentStrategy . IndentationString = editor . Options . IndentationString ;
66+ indentStrategy . Indent ( acc , true ) ;
6167 }
6268
69+ /* NR indent engine (temporarily?) disabled as per #447
6370 static void IndentSingleLine(CacheIndentEngine engine, IDocument document, IDocumentLine line)
6471 {
6572 engine.Update(line.EndOffset);
@@ -83,6 +90,7 @@ static CacheIndentEngine CreateIndentEngine(IDocument document, TextEditorOption
8390 var engine = new CSharpIndentEngine(document, options, formattingOptions.OptionsContainer.GetEffectiveOptions());
8491 return new CacheIndentEngine(engine);
8592 }
93+ */
8694 #endregion
8795
8896 #region Private functions
0 commit comments