dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.08k stars 4.04k forks source link

Code cleanup on save adds extra steps in back (Undo) history #59781

Open vsfeedback opened 2 years ago

vsfeedback commented 2 years ago

This issue has been moved from a ticket on Developer Community.


[regression] [worked-in:I dont know (] If you save a file with the new feature "Cleanup on save" which triggers my current selected "Profile 1" it saves multiple steps in the CTRL+Z History. So if i save my file 5 times i have to press CTRL+Z 6 times to get my current changed text reverted instead of 1 time. I am trigger my file save with CTRL+S. Even if my document is already formatted based on the Profile 1 the issue appears. So i would assume that my file is already correctly formatted based on the profile and if i add something and press save and wants to revert my changes i have to press Undo (CTRL+Z) multiple times.

Is this a known issue?

My Profile settings Be97a01d67fec44d28ca67e96de440748637811297434136185_20220222-132902-image

Hidden parts from the top area B0c32e9916d4b4c0db6ab5499898e0e93637811297755107817_20220222-132935-image

Would be nice to know a fix to prevent this extra steps.


Original Comments

Feedback Bot on 2/22/2022, 06:56 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Feedback Bot on 2/23/2022, 03:34 PM:

Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2019#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.


Original Solutions

(no solutions)

jmarolf commented 2 years ago

This design is intentional. We wanted to have each individual fix application be a separate entry in the undo stack so the developer could decide which set of things to undo in a more granular fashion. Happy to revisit this design though.

tobidemski commented 2 years ago

Maybe I described it wrong or unclear. Even if there isnt any formatting applied because i pressed 5 times CTRL+S (Save) one after the other i have to revert it 6 times to see an actual change. I would expect to press several times the undo button if an actual formatting was applied but i would assume that after pressing the save button for the first time the formatting is applied and the other 4 which saves directly after the first one wouldnt have any impact because there isnt anything to format / cleanup.

So to reproduce it:

Create a new file for example: Test.cs

File looks like:

class Test
{
}

Press Save: (Code cleanup is configured to add a access modifier (internal))

internal class Test
{

}

Press Save 2 (or more) times!

You have to press x times (how often you pressed save + 1) CTRL+Z to revert the "internal" instead of 1 time which what i would expect because after the first save all formatting / cleanup are already applied.

Hope i could explain it a bit more / better.