C# editor. Automatically added code is not removed by undo ( Ctrl-Z ) operations.
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/C-editor-Automatically-added-code-is-n/10985411)._
---
[severity:It bothers me. A fix would be nice]
When I edit a class and unintentionally add some code automatically, undo operations are not working as I expect.
I have to select the code manually and press delete.
Bug1.png shows the class before adding a constructor.
Bug2.png shows the operation that adds the constructor code
bug3.png shows the class with the generated code
bug4.png shows the class after many Ctrl-Z operations. Still nothing of the automatically inserted code removed.
My suggestion is that the automatically entered code becomes code that will be removed in one or a couple of operations with ctrl Z in the order it is entered.
Undo operations are only undoing code I have added to the file myself, but I want the code that is automatically added be a part of the undo stack.
[Bug1.png](https://aka.ms/dc/file?name=Bd9a034d0675944e38f29b1287821b3fa638965470215890945_Bug1.png&tid=d9a034d0675944e38f29b1287821b3fa638965470215890945)
[Bug2.png](https://aka.ms/dc/file?name=Ba24fbd0148b34bf79ca427694785a180638965470430778012_Bug2.png&tid=a24fbd0148b34bf79ca427694785a180638965470430778012)
[Bug3.png](https://aka.ms/dc/file?name=B9a2cca13bf3943df9e2be17a991868cb638965470845684163_Bug3.png&tid=9a2cca13bf3943df9e2be17a991868cb638965470845684163)
[Bug4.png](https://aka.ms/dc/file?name=B40363455ad804e9e8206b134259e9a52638965471003537390_Bug4.png&tid=40363455ad804e9e8206b134259e9a52638965471003537390)
---
### Original Comments
#### Feedback Bot on 10/21/2025, 07:42 AM:
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.
#### Gan Yong Chun (Centific Technologies Inc) [MSFT] on 10/24/2025, 05:02 AM:
Thanks for your sharing the detail steps, I can reproduce this issue through your shared steps and this issue has been escalated for further investigation, if there is any process, I will inform you immediately.
Contributor guide
Research direction
Reproduce the reported C# editor scenario by adding a constructor and then issuing repeated Ctrl-Z operations. Start by tracing how the automatically inserted constructor code is recorded in the editor's undo stack; done means Ctrl-Z removes that generated code in the expected order, with regression coverage for the scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100