Visual Studio 2012 cursor behaviour in locked files

2

When I'm using VS 2012 and I'm running my web application, Visual Studio locks all (compiled) source files and prevents me from editing them. Which is fine, as the debugger is attached and I will still want it to show me the actual executing code when it breaks.

When I try and type or paste something in a file, it will give me a nice popup telling me me I can't change anything while the code is running.

However, and this is the annoying part, some action may move my cursor after closing said popup. When I press Enter the cursor moves to the start of the line. When I try to paste something, it gets worse, because it will jump to the end of the file. And then I have to find the spot I was looking at, which is quite annoying if the file is fairly large. And having to look it up again also complete breaks my train of thought.

Is there any way to prevent this behaviour? When I can't change something, informing me is fine. But I want the cursor to remain exactly where it was and not jump all over the place.

René Wolferink

Posted 2012-12-24T11:42:20.250

Reputation: 121

I'm sorry, I probably mis-undertsand the question, but why don't you stop trying to edit your code during debug? FYI, you don't have to have the debugger running to see your web application, after it starts, the connection remains open (although if you make a change to code you have to perform a build before refreshing the web page) – Dave – 2012-12-24T11:45:28.520

When looking through the code, I sometimes forget that I am still in debug mode when I decide I need to make a change somewhere. That's when it happens. I'm not trying to purposefully change code while debugging (which is why I said it was fine that files get locked). I've never noticed this behaviour in older versions of Visual Studio. Trying to edit a locked file should not result in the cursor changing it's location. – René Wolferink – 2012-12-24T11:53:32.383

2@DaveRook Coz the second you know what you have to do to fix the error, you reflexively jump at the code. So, you hit stop and then the behavior Rene is talking about occurs – mcalex – 2012-12-24T11:59:52.417

Yup, you just want to make the change when you know what to do, forgetting yo're still in debug mode. However, it will already make the cursor jump before you stop debugging, it will already jump after you close the info-popup that you can't make changes while debugging. – René Wolferink – 2012-12-24T12:05:13.407

@RenéWolferink: Are you building in debug or release mode? – James P – 2013-01-03T15:41:41.717

I'm compiling/running in debug mode. – René Wolferink – 2013-01-03T15:42:42.107

In some cases in debug mode you should be able to change the file during debugging using Edit and Continue. If you build in Release mode with Edit and Continue enabled, it will lock the file. – James P – 2013-01-03T15:47:57.707

@RenéWolferink: Is the message you are getting, 'Changes are not allowed if the assembly has not been loaded' or something else? – James P – 2013-01-03T16:02:03.370

1Yes, that is the message I'm getting. But I don't mind that it prevents me from editing. What I mind is that it will move my cursor. So when I stop the solution from running after closing the message and continue with what I wanted to do, my cursor will not be where I was when I first tried to change something. – René Wolferink – 2013-01-03T16:29:54.207

1I totally know what you're talking about. I tried to submit a bug about this to the Connect Feedback thing in visual studio, but the page's scripts error out! – Jason Kleban – 2013-09-22T12:08:03.103

No answers