jupyter-lsp / jupyterlab-lsp

Coding assistance for JupyterLab (code navigation + hover suggestions + linters + autocompletion + rename) using Language Server Protocol
https://jupyterlab-lsp.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.82k stars 148 forks source link

Cursor does not appear when using vim keymap. #240

Open stephenholtz opened 4 years ago

stephenholtz commented 4 years ago

Description

When using vim as the text editor keymap, syntax highlighting obscures the cursor. There don't appear to be any relevant codemirror extensions settings.

Firefox: cursor_problem

$ jupyter --version
jupyter core     : 4.6.3
jupyter-notebook : 6.0.3
qtconsole        : not installed
ipython          : 7.13.0
ipykernel        : 5.2.0
jupyter client   : 6.1.2
jupyter lab      : 2.0.1
nbconvert        : 5.6.1
ipywidgets       : 7.5.1
nbformat         : 5.0.4
traitlets        : 4.3.3
$ jupyter labextension krassowski/jupyterlab-lsp --version
2.0.1

This occurs in Firefox and Chrome on OSX 10.15.4. Although on Chrome the edge of the cursor is just barely visible, so Chrome+zoom page is my current workaround.

Expected behavior

I think the cursor should be visible on top of the highlighting.

krassowski commented 4 years ago

Thank you for opening this issue. I will have a look over the weekend.

krassowski commented 4 years ago

This is difficult and not specific to this extension. Long story short, the cursor is usually placed on top with z-index 1, but in the vim mode it is placed under the text with z-index 3. Now, all the token-based highlighters, including the built-in search of JupyterLab and the match highlighter add-on from codemirror create the highlight effect by adding a background to the token; we cannot have a cursor between the background and the text in HTML (as far as I know).

The line highlight feaure works this problem around by using a custom presentation layer which is below all tokens (and below the cusors); it might be possible to rewrite our highlights to use a similar mechanism (the positioning is possible - this is how cursros are made), but not trivial.

krassowski commented 4 years ago

One way around it would be to change z-index of the cursor to place in at the top and make it semi-transparent (or only border/outline, with transparent inside).

stephenholtz commented 4 years ago

Thanks for looking into this and opening the Jupyterlab issue, it seems like the right place to get a solution implemented.