I'm with you. Bad behaviour but if this was an issue, thousands of users were facing this problem.
So maybe it's something with your mouse as
the code is still editable when you debug. Another idea is the touchpad on a notebook. I switched off ALL special functions (like tap for double click or other functions) due to my big fingers. That crap even has "magic moves" which trigger the hell when you do not know that the pad can do such things
If you double click a variable you can move it with your mouse or delete it. This comes close to the symptoms you describe.