MATLAB-extension-for-vscode
MATLAB-extension-for-vscode copied to clipboard
Warnings shown for files not opened in editor
When a new file is opened in the editor, MATLAB populates the "Problems" panel with its warnings and errors. For example, when a built-in function is opened in the editor (by clicking "Go To Definition" or by ctrl+clicking the function name), its code opens in the editor and we may see a couple warnings. We expect these warnings to leave the "Problems" panel once the file is closed.
However, there is a weird bug where these warnings do not go away even after closing the file. Here I have a script which contained the addpath()
, genpath()
, and imgaussfilt()
functions. None of these files were open in the editor, yet the warnings are still shown (seen below).
The warnings appear even if I just ctrl+hover over the function names. It doesnt always happen, but in most cases it does. What more, sometimes you will see functions that were called by the built-in function. In the screenshot below, imgaussfilt.m
is not there, but another file KernelDistribution.m
is shown, even though it was never opened in the editor.
The appropriate behavior, in my opinion, should be to either
- Show only warnings/errors for files currently open
- Show warnings/errors for all files in the workspace, but exclude built-ins
Hi @goldrik , I am having some trouble reproducing this behavior. For me, the file correctly disappears from the "Problems" panel when the file is closed.
Here are some questions which may help narrow this down:
- Please provide the version numbers for VS Code, the extension, and your MATLAB installation.
- Are you seeing this with every file, or does it only happen with some files (or sporadically)?
- Do you have any other MATLAB-related extensions installed?
I have seen this issue on both Windows and Mac. The best way I've seen it replicated is by holding ctrl and hovering over function names. This populates the PROBLEMS panel with warnings/errors from these files, even though the files are not open themselves. This happens every time (not sporadically).
Opening the file (using "Go To Definition"), then closing it seems to remove the file from the panel, though not always. In this case, it seems sporadic - it may take multiple openings and closings of multiple various files for the issue to reoccur this way. The issue seems to be more prominent for MATLAB built-in functions (like imgaussfilt
).
Mac
- Visual Studio v1.85.1 (Universal)
- MATLAB extension v1.1.5
- MATLAB R2023b (Apple Silicon)
Windows
- Visual Studio v1.85.1 (user setup)
- MATLAB extension v1.1.5
- MATLAB R2023a
I dont have any other MATLAB extension enabled.
Thanks for the clarification! Trying again, I was able to see some odd behavior with this (for example, diagnostics disappearing when closing a file, but then reappearing a bit later).
Thanks for reporting this!