Browse Source

Fix #447: Revert to old indent engine

Re-opens #109 and #144.
pull/463/head
Daniel Grunwald 11 years ago
parent
commit
c11c509e87
  1. 28
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs

28
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs

@ -44,22 +44,29 @@ namespace CSharpBinding.FormattingStrategy @@ -44,22 +44,29 @@ namespace CSharpBinding.FormattingStrategy
#region Smart Indentation
public override void IndentLine(ITextEditor editor, IDocumentLine line)
{
var document = editor.Document;
var engine = CreateIndentEngine(document, editor.ToEditorOptions());
IndentSingleLine(engine, document, line);
int lineNr = line.LineNumber;
DocumentAccessor acc = new DocumentAccessor(editor.Document, lineNr, lineNr);
CSharpIndentationStrategy indentStrategy = new CSharpIndentationStrategy();
indentStrategy.IndentationString = editor.Options.IndentationString;
indentStrategy.Indent(acc, false);
string t = acc.Text;
if (t.Length == 0) {
// use AutoIndentation for new lines in comments / verbatim strings.
base.IndentLine(editor, line);
}
}
public override void IndentLines(ITextEditor editor, int beginLine, int endLine)
{
var document = editor.Document;
var engine = CreateIndentEngine(document, editor.ToEditorOptions());
int currentLine = beginLine;
do {
var line = document.GetLineByNumber(currentLine);
IndentSingleLine(engine, document, line);
} while (++currentLine <= endLine);
DocumentAccessor acc = new DocumentAccessor(editor.Document, beginLine, endLine);
CSharpIndentationStrategy indentStrategy = new CSharpIndentationStrategy();
indentStrategy.IndentationString = editor.Options.IndentationString;
indentStrategy.Indent(acc, true);
}
/* NR indent engine (temporarily?) disabled as per #447
static void IndentSingleLine(CacheIndentEngine engine, IDocument document, IDocumentLine line)
{
engine.Update(line.EndOffset);
@ -83,6 +90,7 @@ namespace CSharpBinding.FormattingStrategy @@ -83,6 +90,7 @@ namespace CSharpBinding.FormattingStrategy
var engine = new CSharpIndentEngine(document, options, formattingOptions.OptionsContainer.GetEffectiveOptions());
return new CacheIndentEngine(engine);
}
*/
#endregion
#region Private functions

Loading…
Cancel
Save