mathworks / jupyter-matlab-proxy

MATLAB Integration for Jupyter enables you to run MATLAB code in Jupyter Notebooks and other Jupyter environments. You can also open MATLAB in a browser directly from your Jupyter environment to use more MATLAB features.
Other
283 stars 36 forks source link

User Preferences not overriding System Defaults (on Windows) #40

Closed tylerlekang closed 1 year ago

tylerlekang commented 1 year ago

System: Windows 10 Matlab 2023a Python 3.8.16 (via Miniconda) Jupyter Lab 3.6.3 (via conda install)

Background: In the JL advanced settings editor (JSON editor), the left pane shows system defaults and right pane is supposed to allow you to override those as you please.

For example, I want to use Ctrl+Shift+R to restart the MATLAB kernel instead of 0,0. So I have in the two panes:

System Defaults menu:

{
            "args": {},
            "command": "kernelmenu:restart",
            "keys": [
                "0",
                "0"
            ],
            "winKeys": {},
            "macKeys": {},
            "linuxKeys": {},
            "selector": "[data-jp-kernel-user]:focus"
        },

User Preferences menu:

{
            "command": "kernelmenu:restart",
            "keys": [
                "Ctrl Shift R"
            ],
            "selector": "[data-jp-kernel-user]:focus",
            "args": {}
        },

ISSUE: This does NOT work. Restart kernel continues to be 0,0.

Attempts to resolve: According to the latest (2022) answer here https://stackoverflow.com/questions/67276693/jupyter-lab-user-override-set-but-not-working-as-expected

a similar issue was resolved by copying exactly the format from the Defaults pane. I tried this, changing the keys to my preference as:

{
            "args": {},
            "command": "kernelmenu:restart",
            "keys": [
                "Ctrl Shift R"
            ],
            "winKeys": {},
            "macKeys": {},
            "linuxKeys": {},
            "selector": "[data-jp-kernel-user]:focus"
        },

but it throws an error when I then try to save this in the User Preferences:

[type error] .shortcuts[55].winKeys should be array

How can we get the user preferences to override the system defaults correctly?

Also, it would be nice to be able to set keyboard shortcuts for some other items, like "restart-and-run-to-selected" which is in the kernel menu without a default shortcut, as well as "run-all-above" which is in the Run menu without a default.

tylerlekang commented 1 year ago

Note: This perhaps could just be an issue with Jupyter Lab (on Windows) and not jupyter-matlab-proxy and thus not belong here?

But I have never ran into this issue in previous use of JL for working on Python. (That was on Linux, for what it's worth.)

philipc-mw commented 1 year ago

Thank you for trying out the MATLAB Integration for Jupyter, and thank you for the detailed issue report!

I was also able to reproduce the issue – it appears to be due to this open JupyterLab issue: https://github.com/jupyterlab/jupyterlab/issues/12294 As you say, support for this issue may be found on that repo, as this issue is not related to the MATLAB integration.

In case it is useful, I will mention that using JupyterLab 3.6.3, in the standard settings editor (not the advanced one) I was able to set "shift+t" as a shortcut. I was not able to set custom shortcuts that used ctrl, however – this is possibly a JupyterLab restriction.

tylerlekang commented 1 year ago

@philipc-mw Thanks for the comment!

For what it is worth (as I mentioned in https://github.com/mathworks/jupyter-matlab-proxy/issues/41 ), this is not an issue when building/editing a MATLAB notebook in VS Code (method for manually setting that up is given in the linked issue).

The shortcuts I setup for notebooks in VSC for Python, are able to persist and be used for MATLAB notebooks as well.