Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

Fixes #69876

@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 23, 2024
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review November 23, 2024 17:22
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner November 23, 2024 17:22

var expected = """
Console.WriteLine("Hello, World!");
Copy link
Member Author

Choose a reason for hiding this comment

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

this result is better. the final formatting matches the initial formatting.

event Action I.e6 { add { } remove { } }
static C() { }
Copy link
Member Author

Choose a reason for hiding this comment

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

this result is better. the final formatting matches the initial formatting.

{
void M()
{
int x;{{leadingTrivia}}
Copy link
Member Author

Choose a reason for hiding this comment

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

this result is better. the final formatting matches the initial formatting.

Copy link
Member Author

Choose a reason for hiding this comment

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

same for the rest of the results.

void M()
{
bool otherFunction() => true;
Copy link
Member Author

Choose a reason for hiding this comment

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

this result is better. the final formatting matches the initial formatting.

static void M() { }
static object P { get; set; }
Copy link
Member Author

Choose a reason for hiding this comment

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

this result is better. the final formatting matches the initial formatting.


var expected = """
using System;
Copy link
Member Author

Choose a reason for hiding this comment

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

this result is better. the final formatting matches the initial formatting.

// adding/removing/modifying modifiers does not mean we want the parent construct to change its formatting
// respective to what's around it.
if (!withLeadingElasticMarker)
list[i] = list[i].WithoutLeadingTrivia();
Copy link
Member Author

Choose a reason for hiding this comment

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

the crux of the fix. we do not want elastic trivia at teh start of a member by default, and especially not if we're just mutating modifiers. We want the modifiers to just be inertly placed into the member, leaving the formatting the same as how it started.

callers can choose if they do want leading elastic trivia added

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fixer for IDE0251 results in poorly formatted code

3 participants