MATLAB-extension-for-vscode icon indicating copy to clipboard operation
MATLAB-extension-for-vscode copied to clipboard

"View Problem" jumps to first code issue

Open michellehirsch opened this issue 2 years ago • 3 comments

When mousing over code with a code analyzer issue, there's a dialog under the message that offers to View Problem or Quick Fix ...

Clicking on View Problem (or using the keyboard shortcut) jumps to the first issue in the file. I'm not positive what View Problem is meant to do, but that's not what I expected. I was expecting more detail - maybe an extended code analyzer message, a doc link, or more info in the Problems panel.

michellehirsch avatar Jun 21 '23 17:06 michellehirsch

Hi Michelle,

I believe that, when using the keyboard shortcut for "View Problem", VS Code tries to apply it to the code analyzer issue at the cursor's location. If the cursor is not at the location of the code analyzer issue, then it jumps to the first message in the document. Can you confirm that this is the behavior you are seeing?

This action should cause VS Code to enter a mode where you can see the info/warning/error text within the document and navigate between messages, like the following: image

dklilley avatar Jun 27 '23 19:06 dklilley

Thanks, Duncan. Similar to my comment on the other issue, I didn't realize that VS code keyed off of the location of the insertion cursor since I was using the mouse to hover over the squiggle without moving the insertion cursor.

I'm mostly seeing the correct behavior. I opened a file with tons of issues, and the feature behaves as expected. If I introduce a new issue, trying to show issue takes me to the first issue in the file.

This is what I see. When I either click on "View Problem" or use the keyboard shortcut, it jumps to what it labels as the first problem. image

I'm also realizing that it is labeling the problems out of order in the file. It shows problem 1 at line 355, problem 2 at 189, 3 at 260, 4 at 363, 5 at 505. The 6th problem is the first one in the file, then it seems on track with next problem taking me to the next problem farther down in the file. I'll email you the file since I can't share it publicly.

michellehirsch avatar Jun 28 '23 11:06 michellehirsch

I agree that the navigation between problems is not intuitive. I am able to reproduce this behavior in other types of files (e.g. Python), so it appears that this is VS Code's behavior. Taking a quick glance, I could not find an open issue on VS Code for this behavior. It may be worth opening an issue on VS Code's repository.

For the ordering of issues, it appears that VS Code orders them primarily by their severity (error, then warning, then info), and secondarily by their position in the document. From your example, problem 1 is the only error in the file, problems 2 through 5 are the warnings, and problem 6 is the first info message in the file.

dklilley avatar Jun 28 '23 13:06 dklilley

Closing this issue, as this is VS Code's inherent behavior

dklilley avatar Oct 09 '24 15:10 dklilley