Skip to content

"MATLAB:Run Current Section" does not stop at breakpoint #338

Open

Description

@cuixing158

Describe the bug
when I only care about a specific section (lines starting with double %). When I want the debugger to pause at a certain line of code in that section, provided I’ve already set a breakpoint there, if I run the section using “MATLAB: Run Current Section”, the code executes the entire section directly and ignores the breakpoint!

To Reproduce
Steps to reproduce the behavior:
Create a new script .m file and insert the following code.

a = 1;
b = 2;

%% section debug,can't stop at line 5
c = a + b; % line 5, have breakpoint
fprintf('c = %d\n', c);
  1. add a breakpoint at line 5.

  2. place the mouse cursor on line 5.

  3. press the F1 shortcut and select “MATLAB: Run Current Section”, or press Ctrl+Enter to run the current section.

The breakpoint does not pause at line 5; instead, the code runs straight through as if you had pressed Run.

Expected behavior
The code enters debugging mode and pauses at line 5

Screenshots
Image

Useful Information

  • MATLAB Version: R2026a
  • OS Version: win10 22H2
  • VS Code Version: Version: 1.125.1 (system setup)
    Commit: fcf604774b9f2674b473065736ee75077e256353
    Date: 2026-06-19T08:39:34Z
    Electron: 42.2.0
    ElectronBuildId: 14159160
    Chromium: 148.0.7778.97
    Node.js: 24.15.0
    V8: 14.8.178.14-electron.0
    OS: Windows_NT x64 10.0.19045

Additional context
None

Activity

  1. dklilley commented on Jun 23, 2026

    @dklilley
    Member

    Hi @cuixing158 , thanks for reaching out about this issue!

    I have two clarifying questions:

    1. Is the breakpoint also skipped if you run the entire file (rather than just the section)?

    2. Is the breakpoint hit if you first select "Start Debugging" from VS Code's "Run" menu before running the section?

  2. cuixing158 commented on Jun 23, 2026

    @cuixing158
    Author

    For question 1:
    When I run the entire file ,it can hit breakpoint

    Question 2:
    When I first select "start debug",only as I don't select“MATLAB:Run Current section ",it can hit breakpoint

  3. dklilley commented on Jun 23, 2026

    @dklilley
    Member

    Thanks for the clarification! I am able to reproduce this on my end as well.

  4. philipb314 commented on Jun 30, 2026

    @philipb314
    Member

    Thanks for reporting this issue. This is something that we can reproduce and will look into resolving in a future release of the extension. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions