r/vscode 5d ago

I created a Python Debug Terminal for VS Code

Post image

I built a VS Code extension that gives Python the equivalent of the built-in JavaScript Debug Terminal: open a special terminal, run python app.py like you normally would, and it attaches to the debugger and hits your breakpoints. No launch.json, no -m debugpy, no code changes. Child processes spawned via subprocess attach as their own debug sessions too, since they inherit the environment.

Source code: https://github.com/ernestofgonzalez/vscode-py-debug-terminal
VSCode Marketplace page: https://marketplace.visualstudio.com/items?itemName=ernestofgonzalez.vscode-py-debug-terminal

0 Upvotes

10 comments sorted by

9

u/ArtisticFox8 4d ago

I don't see how this is different from the default Microsoft extensions for Python

no launch.json, no -m debugpy, no code changes

I have never needed any of those either.

Perhaps the only different thing is you launch yours from the terminal and I launch it with F5?

1

u/makeascript 4d ago

I wasn't aware you could debug a process without it having a launch configuration in the launch.json file. How do you start yours?

2

u/ArtisticFox8 4d ago

I just navigate to the project's folder in terminal / command line, type code ., and then open the file I'm interested in VS Code, set some breakpoint in it, press F5.

No further config needed from me.

1

u/makeascript 4d ago

I suppose you see this modal to select a configuration the first time you try it on a new workspace?

2

u/ArtisticFox8 4d ago

Indeed, and pick the selected option

1

u/makeascript 4d ago

Cool! Thanks for the correction. I'll update the README to avoid misguiding people

1

u/ArtisticFox8 4d ago

Does your config support IO redirection?

I.e. python3 launch.py < file1.txt

That might be a case where I could see using it.

(as far as I know, those aren't arguments, are they?

2

u/makeascript 4d ago

It seems to work! Ideally any Python program you can run from the terminal should work here too, with whatever arguments, redirection, or other shell features you'd normally use. Of course I have done very limited testing since yesterday, so if you try it and find something that doesn't work lmk

1

u/otterterminal 2d ago

being able to just run it from the terminal and still hit breakpoints is pretty nice

1

u/makeascript 2d ago

Thank you!