-
Notifications
You must be signed in to change notification settings - Fork 420
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
Format range #1043
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ba6e969
Added test for failing cases
akshita31 4e16b20
Using full span of the intersecing token
akshita31 41ffcc7
Added test for multiple lines
akshita31 e5383ee
Added text instead of array of changes in the tests
akshita31 40098ee
Removed unnecessary line
akshita31 18955cf
Using string literals
akshita31 35117b1
Added Space
akshita31 c54de26
Merge branch 'master' into format_range
DustinCampbell a204624
Merge branch 'master' into format_range
DustinCampbell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
{ | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -235,11 +226,9 @@ public static void Main() | |
} | ||
}"; | ||
|
||
await AssertTextChanges(string.Join("\r\n", source), expected); | ||
await AssertTextChanges(source, expected); | ||
} | ||
|
||
|
||
|
||
[Fact] | ||
public async Task FormatRespectsIndentationSize() | ||
{ | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
var startPosition = new LinePosition(change.StartLine, change.StartColumn); | ||
var endPosition = new LinePosition(change.EndLine, change.EndColumn); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blanks