mathworks / MATLAB-extension-for-vscode

This extension provides support for editing MATLAB® code in Visual Studio® Code and includes features such as syntax highlighting, code analysis, navigation support, and more.
https://marketplace.visualstudio.com/items?itemName=MathWorks.language-matlab
MIT License
234 stars 15 forks source link

Add breakpoints using dbstop #57

Open goldrik opened 1 year ago

goldrik commented 1 year ago

I have been experimenting with a workflow which involves editing MATLAB files using vs code, then running them by calling the script through an open MATLAB command window (separate from vs code).

Suppose you have a MATLAB script. You can add a breakpoint by using dbstop, like so

Screenshot 2023-09-13 at 5 00 18 PM (3)

By running the script through the MATLAB command window, I get

Screenshot 2023-09-13 at 5 00 35 PM (2)

Which creates a debug point here

Screenshot 2023-09-13 at 5 00 35 PM (3)

I feel like there could be functionality to add breakpoints this way (for now). Perhaps adding a breakpoint in vs code could automatically add the line dbstop at [line number add 1] in [current file]

I know there is work to integrate MATLAB debugging in vs code, but this could be a simple workaround for now.

Edit: Apparently, the keyboard command may work better in this case. I have never tried this, but it could be a preferable alternative to the clunky dbstop line. Still, something to bind the add/remove debug point shortcut to this command would be great.