-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to prevent the debugger stealing the focus from the debug console. #193462
Comments
|
I've tried that option but doesn't solve my problem. Notice in my case the debugger is stopped in a breakpoint already, then I move the editor somewhere else and I send to the debug console some code that opens a matplotlib plot. When I close the plot the editor jumps back to the breakpoint location where the program counter is and I lose the editor view I had. This is very annoying when I want to run my script with some data, stop it at a breakpoint and then experiment with/analyse the data and processing I do to it at a previous point in the function/stack. The editor keep jumping back to the PC location when closing plot windows and I have to again repeatedly find the piece of code I was analysing, which breaks my focus on the problem I'm trying to solve. Notice I'm not stepping through code, I'm just probing parts of the code in the debug console. |
Oh, it's a slightly different scenario than I assumed, however I can't repro it. So you just click X to close the matplotlib window, then when the vscode is focused again, the editor moves back to where the debugger is paused? I don't see this happening, could you share the code that you run in the debug console to make sure I am trying the same scenario? A screen recording might help too. https://gifcap.dev/ |
Yes, that's correct. |
Hey @roblourens, this issue might need further attention. @martinakos, you can help us out by closing this issue if the problem no longer exists, or adding more information. |
Hi, sorry I had other work to do and I couldn't look at this. I found a test case. I use one of matplotlib examples, tricontour_demo.py. . I have added a plt.ion() after importing matplotlib as I want to plot things interactively while I'm in a breakpoint. The only thing special about this script is that it's long, so that I can illustrate the issue. I first put a breakpoint at the bottom, I scroll to the top, evaluate a few lines from the code in the debug console (as I would typically be doing when I'm debugging a script), for that I just select what I wan to evaluate and I have a shortcut to send it to the debug console. Then I create a new matplotlib figure in the debug console, and the editor position jumps to the breakpoint position! That's what I would like to avoid, as that forces me to have to move the editor again to wherever I was before I can continue with my debugging, breaking my concentration. Notice I launch the debugger with a launch configuration. See attached video: debugger_stealing_focus_example.mp4 |
Now I can repro. Seems to be caused by |
My interpretation of what that does is that you are paused in the debugger, and running a command in the debug console runs on a second thread. Since the timeout is 0, it is considered blocked, and debugpy does something to unblock it, which ends up "refreshing" the paused thread in the editor. You can see the callstack blink momentarily. So the editor ends up focused because from vscode's perspective, the debugger actually continued then paused again, so it will do the same thing it does when hitting a breakpoint. Does that make sense? |
While I debug computer vision/geometric code I often visualise point clouds using the Open3D visualiser. This visualiser blocks while I'm inspecting the point cloud and until I close the window. While the Open3D visualiser is opened I keep getting repeated messages in the the debug console telling me that the evaluation is very slow and it may be deadlocked. I set these PYDEVD_xxx environment variables in my launch configurations to silence all these messages. |
Ok. You might check whether using |
Based on my question in vscode-python:
microsoft/vscode-python#22017 (comment)
I want to be able to work with the debug console without the debugger stealing focus and repositioning the editor. Specially don't reposition the editor unless there is stepping through the code. The focus seems to get stolen when closing plot windows (matplotlib, open3d) launched from the debug console.
I've checked these similar issues:
vscodenpa/testissues#9533
#162873
microsoft/vscode-python-debugger#533
but none give me a solution.
Also I have tried disabling the Debug: Focus Editor On Break and Debug: Focus Window on Break options but don't stop this behaviour.
The text was updated successfully, but these errors were encountered: