The (now removed) formatting logic was inherently flawed, so I decided to remove it altogether
The "short" run-down of why the current logic didn't work was the fact that it used the first line with whitespace in it, and then the last whitespace on that line. It then went on to nuke that amount of whitespace from each and every subsequent line, failing to remove whitespace if it had less than that
So in examples like this
// Some cool comment
void MyThing()
{
Console.WriteLine("hello");
DoSomeMoreStuff();
}
It would pick the first whitespace from the comment, the start being before "Some" and the end being between "cool" and "comment" (11 characters of whitespace), completely ignoring that there might not have been whitespace inbetween those occurences of whitespace in the first place.
Now, if we remove the comment altogether, we end up with the next line with whitespace as the Console.WriteLine line, this has 4 spaces. This leads to the whitespace being removed entirely for both Console.WriteLine and the subsequent line.
Ergo inconsistent indentation depending on how you wrote the code.
The idea here is that we can't possibly deal with all of the edge-cases if we were to roll our own code-formatting, so we either
a) Don't deal with it at all, and present the code back to the user exactly as they wrote it
b) Introduce opinionated formatting wherever we want to, i.e. via roslyn
Affects:
The (now removed) formatting logic was inherently flawed, so I decided to remove it altogether The "short" run-down of why the current logic didn't work was the fact that it used the first line with whitespace in it, and then the last whitespace on that line. It then went on to nuke that amount of whitespace from each and every subsequent line, failing to remove whitespace if it had less than that So in examples like this
It would pick the first whitespace from the comment, the start being before "Some" and the end being between "cool" and "comment" (11 characters of whitespace), completely ignoring that there might not have been whitespace inbetween those occurences of whitespace in the first place. Now, if we remove the comment altogether, we end up with the next line with whitespace as the Console.WriteLine line, this has 4 spaces. This leads to the whitespace being removed entirely for both Console.WriteLine and the subsequent line. Ergo inconsistent indentation depending on how you wrote the code.
The idea here is that we can't possibly deal with all of the edge-cases if we were to roll our own code-formatting, so we either a) Don't deal with it at all, and present the code back to the user exactly as they wrote it b) Introduce opinionated formatting wherever we want to, i.e. via roslyn
Fixes #975