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

Warnings shown for files not opened in editor #80

Open goldrik opened 9 months ago

goldrik commented 9 months ago

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).

Screenshot 2024-01-05 at 4 20 28 PM 2

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.

Screenshot 2024-01-05 at 4 36 10 PM 2

The appropriate behavior, in my opinion, should be to either

dklilley commented 9 months ago

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:

goldrik commented 8 months ago

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

Windows

I dont have any other MATLAB extension enabled.

dklilley commented 8 months ago

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!