Skip to content

VS Code Workspace sidebar does not show variables when script contains clear, close all, and figure #332

Description

@Achuan-2

Describe the bug

When a MATLAB script contains clear;, close all;, and figure; together, variables created by running the script do not appear in the VS Code Workspace sidebar.

The variables do exist in the MATLAB workspace and can be seen in the external MATLAB Workspace window opened with the workspace command. The issue seems to be specific to the VS Code Workspace sidebar not refreshing or syncing correctly.

To Reproduce

Steps to reproduce the behavior:

  1. Open VS Code with the MATLAB extension active.
  2. Create a MATLAB script file with the following content:
    clear;
    close all;
    a = 1
    figure;
  3. Type workspace in the MATLAB terminal to open the external MATLAB Workspace window.
  4. Run the script in VS Code.
  5. Check the VS Code Workspace sidebar. Observe that variable a is not shown in the VS Code Workspace sidebar.
  6. Observe that variable a is shown correctly in the external Workspace window.

Expected behavior

The VS Code Workspace sidebar should display variable a after the script finishes running, since the variable exists in the MATLAB workspace.

Screenshots

Image

Useful Information

  • MATLAB Version: 2023b
  • OS Version: Win 11
  • VS Code Version: 1.124.2
  • MATLAB Extension Version: v1.3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions