Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format range #1043

Merged
merged 9 commits into from
Dec 11, 2017
89 changes: 39 additions & 50 deletions tests/OmniSharp.Roslyn.CSharp.Tests/FormattingFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,14 @@ await AssertTextChanges(string.Join("\r\n", source),
[Fact]
public async Task TextChangesOnStaringSpanBeforeFirstCharacterInLine()
{
var source = new[]
{
"class Program",
"{",
" public static void Main()",
" {",
"[| int foo = 1;|]",
" }",
"}",
};
var source =
@"class Program
{
public static void Main()
{
[| int foo = 1;|]
}
}";

var expected =
@"class Program
Expand All @@ -153,23 +151,20 @@ public static void Main()
}
}";

await AssertTextChanges(string.Join("\r\n", source), expected);
await AssertTextChanges(source, expected);
}

[Fact]
public async Task TextChangesOnStartingSpanAtFirstCharacterInLine()
{
var source = new[]
{
"class Program",
"{",
" public static void Main()",
" {",
" [|int foo = 1;|]",
" }",
"}",
};

var source =
@"class Program
{
public static void Main()
{
[|int foo = 1;|]
}
}";
var expected =
@"class Program
{
Expand All @@ -179,22 +174,20 @@ public static void Main()
}
}";

await AssertTextChanges(string.Join("\r\n", source), expected);
await AssertTextChanges(source, expected);
}

[Fact]
public async Task TextChangesOnStartingSpanAfterFirstCharacterInLine()
{
var source = new[]
{
"class Program",
"{",
" public static void Main()",
" {",
" i[|nt foo = 1;|]",
" }",
"}",
};
var source =
@"class Program
{
public static void Main()
{
i[|nt foo = 1;|]
}
}";

var expected =
@"class Program
Expand All @@ -205,24 +198,22 @@ public static void Main()
}
}";

await AssertTextChanges(string.Join("\r\n", source), expected);
await AssertTextChanges(source, expected);
}

[Fact]
public async Task TextChangesOnStartingSpanAfterFirstCharacterInLineWithMultipleLines()
{
var source = new[]
{
"class Program",
"{",
" public static void Main()",
" {",
" i[|nt foo = 1;",
" bool b = false;",
" Console.WriteLine(foo);|]",
" }",
"}",
};
var source =
@"class Program
{
public static void Main()
{
i[|nt foo = 1;
bool b = false;
Console.WriteLine(foo);|]
}
}";

var expected =
@"class Program
Expand All @@ -235,11 +226,9 @@ public static void Main()
}
}";

await AssertTextChanges(string.Join("\r\n", source), expected);
await AssertTextChanges(source, expected);
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra blanks



[Fact]
public async Task FormatRespectsIndentationSize()
{
Expand Down Expand Up @@ -347,7 +336,7 @@ private async Task AssertTextChanges(string source, string expected)
public static IEnumerable<TextChange> GetTextChanges(SourceText oldText, IEnumerable<LinePositionSpanTextChange> changes)
{
var textChanges = new List<TextChange>();
foreach( var change in changes)
foreach(var change in changes)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foreach (var change ...)

{
var startPosition = new LinePosition(change.StartLine, change.StartColumn);
var endPosition = new LinePosition(change.EndLine, change.EndColumn);
Expand Down