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
241 stars 16 forks source link

Opening figures, simulink models, etc. in VS Code #188

Open Gusmano-2-OSU opened 2 weeks ago

Gusmano-2-OSU commented 2 weeks ago

Implements opening .fig, .slx and other MATLAB files through VS code's context menu.

Note! I'm brand new to developing in TypeScript, and I'm having some implementation issues (specifically, getting the menu option to occur in the context menu.) Still, I wanted to put this here in case @dklilley or any of the other maintainers want to help with the final steps!

dklilley commented 1 week ago

Hi @Gusmano-2-OSU, thanks for working on this! I will plan to take a look at this soon (likely early next week).

Before I take a look, I just wanted to clarify - you are having some difficulty getting the "MATLAB: Open File" option added into the context menu?

Gusmano-2-OSU commented 1 week ago

Hey @dklilley, that's exactly right! The idea is, you right click any file supported by MATLAB's open command, and you get a context menu command that lets you run the command on that file. As someone who works a lot with figures and Simulink models, I'm hoping it can significantly increase the speed of my workflow!

My dream implementation of this is that a normal click would open these files as a tab in the current vs code window, but it would definitely be good enough if they opened in a separate MATLAB window.

Thanks for taking a look!

dklilley commented 4 days ago

I believe that the issue is just with where the configuration for the context menu item was being added within package.json. Take a look at my comment and see if it helps!

Gusmano-2-OSU commented 4 days ago

Hey @dklilley, thanks for the suggestions! I was able to get it to work with the tips you gave. As I tried it out though, I thought it would be a little slow to open one at a time, so I tried adding functionality to select multiple files, and then executing the command to open all of them. I think there's a slight issue with the for loop, but I'm requesting the review anyway to show that the last problem was fixed! Do you have any suggestions on how to fix for loop issue?

dklilley commented 3 days ago

I don't think there are any issues with the loop as you have written it. Instead, even if there are multiple files selected in the Explorer, only one URI is passed to the command.

Unfortunately, after some digging, I don't believe that this is functionality which is publicly available for extensions to leverage.

While there are some context menu actions which do work with multiple files selected (e.g. Open to the Side), these are commands provided my Microsoft and are implemented internally (e.g. the implementation of Open to the Side leverages an internal getMultiSelectedResources API).

Gusmano-2-OSU commented 3 days ago

That's too bad - maybe a project for another day if we could ever use the getMultiSelectedResources API. For now, I've reverted the commit and this should be ready to pull!

dklilley commented 3 days ago

Agreed - hopefully they add some public functionality soon!

The changes look good to me! One of my colleagues will be reaching out soon with information about signing the CLA.

nothans commented 1 day ago

Hi. Thanks for the contribution! Can you contact me about signing the CLA? I can help from there. Thanks.

Gusmano-2-OSU commented 1 day ago

I sent you an email, @nothans!