jupyterlab-lsp icon indicating copy to clipboard operation
jupyterlab-lsp copied to clipboard

jupyterlab-lsp breaks multicursor support (box-selection via [alt] + mouse dragging)

Open randolf-scholz opened this issue 3 years ago • 4 comments
trafficstars

Description

With this extension enabled multi-cursor selection via [alt]+mouse-drag ceases to work in jupyterlab.

Reproduce

  1. conda create --name demo -c conda-forge jupyterlab jupyterlab-lsp python-lsp-server
  2. conda activate demo
  3. jupyter lab
  4. Start jupyter lab and try to select multiple lines using [alt] + mouse-drag. Shouldn't work
  5. Stop jupyter lab. Disable extension jupyter-labextension disable @krassowski/jupyterlab-lsp
  6. Restart jupyter lab. multi-cursor selection via [alt] + mouse-drag should work fine.

Expected behavior

Context

  • Operating System and version: Ubuntu 22.04
  • Browser and version: Chrome 104.0.5112.79
  • JupyterLab version: 3.4.5
  • Language server and version: python-lsp-server=1.2.1, python-lsp-jsonrpc=1.0.0, jupyterlab-lsp=3.10.1, jupyter-lsp=1.5.1
Required: installed server extensions
Config dir: /home/rscholz/.jupyter

Config dir: /home/rscholz/miniconda3/envs/lsp/etc/jupyter jupyter_lsp enabled - Validating jupyter_lsp... jupyter_lsp 1.5.1 OK jupyterlab enabled - Validating jupyterlab... jupyterlab 3.4.5 OK nbclassic enabled - Validating nbclassic... nbclassic 0.4.3 OK notebook_shim enabled - Validating notebook_shim... notebook_shim OK

Config dir: /usr/local/etc/jupyter

Required: installed lab extensions
JupyterLab v3.4.5
/home/rscholz/miniconda3/envs/lsp/share/jupyter/labextensions
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
        @krassowski/jupyterlab-lsp v3.10.1 enabled OK (python, jupyterlab-lsp)

randolf-scholz avatar Aug 10 '22 19:08 randolf-scholz

I believe that this is because the default key modifier for code jump is Alt. You can change the key modifier in settings:

Screenshot from 2022-08-10 22-10-51

krassowski avatar Aug 10 '22 21:08 krassowski

Thank you, that workaround solves it for now. I also found a related comment here https://github.com/jupyter/notebook/issues/4761#issuecomment-1123067209.

randolf-scholz avatar Aug 11 '22 08:08 randolf-scholz

Do you have suggestions for improving the situation? It seems that both Alt and Ctrl click are used by the mutlicursor support, so that leave no way to have click to jump without introducing a conflict.

krassowski avatar Aug 11 '22 19:08 krassowski

Just spitballing a few ideas:

  • [Alt] + left click currently seems to do nothing on its own, so if a check is introduced that the user isn't selecting stuff (possibly by checking mouse travel distance between button down and button release), it could be left as-is.
  • Change it to [Alt]+ middle mouse button instead of [alt] + left-click
    • Disadvantage: Jupyter currently uses middle mouse click for pasting, must make sure to not introduce another conflict
  • Change default modifier to [shift] or something else

randolf-scholz avatar Aug 15 '22 11:08 randolf-scholz

Maybe it would be sufficient to ensure that instead of mousedown (/pointerdown) triggering the jump we would wait for mouseup.

Of note, CodeMirror 6 used in JupyterLab 4 has rectangularSelection.eventFilter⁠; I do not think it would solve the problem directly, but maybe it could be helpful.

krassowski avatar Apr 12 '23 06:04 krassowski