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
237 stars 15 forks source link

Mac - Cannot launch separate MATLAB application when MATLAB is connected in Visual Studio Code #9

Open wattah1002 opened 1 year ago

wattah1002 commented 1 year ago

Issue Description

When I connect to MATLAB in Visual Studio Code and try to open the MATLAB editor, the editor does not launch without any errors. After disconnecting to MATLAB in Visual Studio Code, the editor launch.

Steps to Reproduce

  1. Open Visual Studio Code
  2. Connect to MATLAB using the MATLAB extension
  3. Launch MATLAB editor from Launchpad

Expected Behavior

The MATLAB editor should launch.

Actual Behavior

MATLAB editor does not launch.

System Information

dklilley commented 1 year ago

Thank you for reporting this!

Workaround: Launch MATLAB via the terminal. For example -

cd /Applications/MATLAB_R2022b.app/bin
./matlab

or

open -n /Applications/MATLAB_R2022b.app

This seems to be related to a behavior on Mac which attempts to limit the number of MATLAB instances at a time - clicking MATLAB from the Launchpad attempts to focus an existing instance instead of spawning a new one. In this case the active instance is hidden, so it appears that nothing has happened.

We are looking into ways of addressing this.

versionbayjc commented 1 year ago

Yes, this is a problem I've now seen a couple of times myself. Not the Editor specifically, but just MATLAB doesn't open at all on macOS if the VS Code MATLAB extension is connected to a MATLAB. The first couple of times I was really surprised why MATLAB wouldn't start. I hope this can be addressed rather soon, since I will probably be defaulting to using the extension without connection to MATLAB (on macOS) while this is the case.

wattah1002 commented 1 year ago

Thank you for providing the workaround. Launching MATLAB via the terminal has proven to be effective.

I understand that this behavior is specific to Mac and is related to the limitation on the number of MATLAB instances. Clicking MATLAB from the Launchpad tries to focus on an existing instance rather than opening a new one, which results in the active instance being hidden.

I appreciate your efforts in investigating ways to address this bug. Please keep me updated on any progress or potential solutions that may arise.

dklilley commented 7 months ago

I wanted to provide an update on this issue: We are actively working to resolve this issue. Because the root cause of this is within MATLAB itself, the fix for this will be tied to a future MATLAB release.

afugls commented 6 months ago

I assume this problem also prevents the desktop feature (mentioned here https://blogs.mathworks.com/matlab/2024/03/05/matlab-extension-for-visual-studio-code-now-with-code-execution/ ) from working on mac?

dklilley commented 6 months ago

Hi @afugls - I do not believe there should be a problem with that. This issue should only prevent a new instance of MATLAB to be launched on Mac. However, the desktop command should just display the MATLAB GUI for the instance of MATLAB already connected in VS Code.

If you encounter any issues with this, please let us know!

afugls commented 6 months ago

Hi @afugls - I do not believe there should be a problem with that. This issue should only prevent a new instance of MATLAB to be launched on Mac. However, the desktop command should just display the MATLAB GUI for the instance of MATLAB already connected in VS Code.

If you encounter any issues with this, please let us know!

Hi @dklilley - I see that it "works" but maybe not as I expected. That is I want to:

  1. Open VC Code and a .m file.
  2. Connect to MATLAB
  3. Type desktop in the MATLAB termnial Expected: A MATLAB GUI should appear in the forefront or in the dock. Actual: MATLAB GUI opens in the "background". That is, I can see the GUI if I show all open windows (ctrl+up arrow on Mac), but I cannot, for example, cmd+tab to the GUI or click on it in the dock.

I assume this is because the connected MATLAB instance is hidden as mentioned above. However, it is not a very intuitive behavior (at least not as a first time user).

dklilley commented 6 months ago

I see - thank you for the clarification!

Yes, I believe this is a side effect of the MATLAB instance being hidden. Would you mind creating a new issue specifically for this behavior with the desktop command?