Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Format issue when TextEditorOptions.TabsToSpaces is false #523

Open
kyubuns opened this issue Oct 28, 2016 · 0 comments
Open

Format issue when TextEditorOptions.TabsToSpaces is false #523

kyubuns opened this issue Oct 28, 2016 · 0 comments

Comments

@kyubuns
Copy link

kyubuns commented Oct 28, 2016

This is the problem code.
I want to change Space Indent to Tab Indent.

// use Bridge.NRefactory.5.5.4
using System;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.Editor;

namespace Foo
{
  class MainClass
  {
    public static void Main (string [] args)
    {
      var policy = FormattingOptionsFactory.CreateMono();
      var formatter = new CSharpFormatter(policy);
      formatter.TextEditorOptions.TabsToSpaces = false;

      var text = @"
namespace Foo
{
    public class Bar
    {
        public void MethodA()
        {
            Promise.All
            (
                MethodB(),
                MethodC(),
                () => {}
            );
        }
    }
}
";
      var document = new StringBuilderDocument(text);
      var syntaxTree = SyntaxTree.Parse(document, document.FileName);
      var changes = formatter.AnalyzeFormatting(document, syntaxTree);
      changes.ApplyChanges();

      Console.WriteLine(document.Text.Replace('\t', '>'));
      Console.ReadLine();
    }
  }
}

Output
(Replace Tab to ">" for github)

namespace Foo
{
>public class Bar
>{
>>public void MethodA ()
>>{
>>>Promise.All
            (
>>>>MethodB (),
>>>>MethodC (),
>>>>() => {
>>>>}
>>>);
>>}
>}
}

Why does Line 8 have white space indent?

@kyubuns kyubuns changed the title Format bug when TextEditorOptions.TabsToSpaces is false Format issue when TextEditorOptions.TabsToSpaces is false Oct 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant