When commenting out a block of XAML/XML that already contains comments, the existing comments are currently modified and are not correctly restored when the block is uncommented.
I think this could be solved by temporarily escaping existing comments inside the selected block.
Example
Starting with:
<Grid>
<!-- This is an important comment -->
<Label Text="Test" />
</Grid>
Commenting the block could temporarily transform the existing comment:
<Grid>
<!~~ This is an important comment ~~>
<Label Text="Test" />
</Grid>
and then wrap the entire block:
<!--
<Grid>
<!~~ This is an important comment ~~>
<Label Text="Test" />
</Grid>
-->
When uncommenting, the outer comment is removed and the escaped comment is restored:
<Grid>
<!-- This is an important comment -->
<Label Text="Test" />
</Grid>
Supporting multiple levels
It would be even better if this mechanism supported multiple consecutive Comment operations.
For example:
Original:
<!-- Comment -->
Comment:
<!~~ Comment ~~>
Comment again:
<!~~~ Comment ~~~>
Comment again:
<!~~~~ Comment ~~~~>
Each Uncomment operation would then remove exactly one level:
<!~~~~ Comment ~~~~>
↓ Uncomment
<!~~~ Comment ~~~>
↓ Uncomment
<!~~ Comment ~~>
↓ Uncomment
<!-- Comment -->
This would make the Comment/Uncomment operation fully reversible, even when the same block is commented out multiple times.
The exact escape characters are just a suggestion. The important part is that existing comments are treated as nested comments and that each Comment/Uncomment operation changes exactly one nesting level.
Expected behavior
The fundamental requirement would be:
Every Comment operation adds one level, and every Uncomment operation removes exactly one level.
Existing comments inside the selected block must not be lost or converted into plain text.
This would be especially useful for XAML/XML, where comments are commonly present inside larger blocks that developers temporarily disable during development.
When commenting out a block of XAML/XML that already contains comments, the existing comments are currently modified and are not correctly restored when the block is uncommented.
I think this could be solved by temporarily escaping existing comments inside the selected block.
Example
Starting with:
Commenting the block could temporarily transform the existing comment:
and then wrap the entire block:
When uncommenting, the outer comment is removed and the escaped comment is restored:
Supporting multiple levels
It would be even better if this mechanism supported multiple consecutive Comment operations.
For example:
Each Uncomment operation would then remove exactly one level:
This would make the Comment/Uncomment operation fully reversible, even when the same block is commented out multiple times.
The exact escape characters are just a suggestion. The important part is that existing comments are treated as nested comments and that each Comment/Uncomment operation changes exactly one nesting level.
Expected behavior
The fundamental requirement would be:
Every Comment operation adds one level, and every Uncomment operation removes exactly one level.
Existing comments inside the selected block must not be lost or converted into plain text.
This would be especially useful for XAML/XML, where comments are commonly present inside larger blocks that developers temporarily disable during development.