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

Format issue when TextEditorOptions.TabsToSpaces is false #523

@kyubuns

Description

@kyubuns

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions