# Undo history cleared after removing comments - bug?

If I've written some code followed by a comment, like this:

x(*y*)


and I remove the comment by first removing the right delimiter and then the left, my undo history is cleared. Here are some conditions for this to occur:

• It doesn't matter whether I remove the * or the parentheses, or both

• Some code must precede the comment. Brackets, semicolons and commas don't seem to count.

• The comment cannot be empty.

Has anyone else experienced this? Is there a way to fix it?

I'm on 10.1, Student Edition.

• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. May 23, 2015 at 23:12
• What, precisely, is the issue? May 23, 2015 at 23:16
• It's right there in the title. May 23, 2015 at 23:21
• Can you post the output of $Version? May 23, 2015 at 23:54 • "10.1.0 for Microsoft Windows (64-bit) (March 24, 2015)" May 23, 2015 at 23:59 ## 2 Answers In an attempt to reproduce this issue, I began with $Version
(* "10.1.0  for Microsoft Windows (64-bit) (March 24, 2015)" *)


I then typed

x(*y*)


and deleted by hand the left asterisk, right asterisk, left parenthesis, and right parenthesis in turn.

xy


Next I began Edit>Undo until I reached

x (y*)


At that point, Undo was not grayed out, so the queue presumably was not empty. Nonetheless, the final Undo was greeted by a beep, and the final asterisk was not restored. Moreover, Undo became grayed out. Selecting Help>Why the Beep? returned the message, Cannot undo the last operation. So, I did not reproduce the issue given in the question, but I certainly obtained unexpected results.

On the other hand, when I deleted first the parentheses and then the asterisks in turn, I was able to restore all four characters using Edit>Undo.

• By "second delimiter" I meant the right one. You have to remove either the right asterisk or parenthesis (or both), and then either the left asterisk or parenthesis (or both). I made some edits to OP to clarify. May 24, 2015 at 11:30

If I use menu Edit > Un/Comment Selection (Windows: Alt+/) the operation can be reversed with the Undo command. This is faster anyway and prevents broken syntax and syntax highlighting that occurs when you remove half a comment marker.

(I post this as an answer because I hope it is pragmatically just that.)