Skip to content

Conversation

@Jessie-Newman
Copy link
Contributor

@Jessie-Newman Jessie-Newman commented May 3, 2022

References

Fixes #8207

Code changes

When text is highlighted in vim mode we set a background color to it. Because the cursor appears behind the background, the cursor is entirely hidden if it is on a highlighted character. This sets the background color to be slightly transparent so the cursor is still visible. Works in both light and dark mode.

User-facing changes

Light mode
Screen Shot 2022-05-03 at 1 39 14 PM

Dark mode
Screen Shot 2022-05-03 at 1 39 01 PM

Backwards-incompatible changes

N/A


Edited to link the associated issue

@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@github-actions github-actions bot added Design System CSS pkg:themes tag:CSS For general CSS related issues and pecadilloes labels May 3, 2022
@Jessie-Newman
Copy link
Contributor Author

The actual correct way to fix this would be to, instead of showing the cursor as a div that moves around the page and sits behind the text, to update the background-color on the selected character. This would give us more flexibility in terms of color. Rather than using a transparent background, we could have selected text and the cursor not overlay at all. We could also specify the color of the selected character (right now for example, if the green cursor is on a green character, it's mostly unreadable).

However the cursor logic is inside of the CodeMirror package and would require changes to that directly. Additionally, changing the cursor from a div to a character background-color would be a very extensive change to their code.

So this translucent background-color solution, while less than perfect, is much smaller and requires no changes to other codebases.

@fcollonval fcollonval added this to the 4.0 milestone May 4, 2022

--jp-inverse-layout-color0: white;
/* Separated rbg values to allow passing into rgba. */
--jp-inverse-layout-color0: 155, 155, 155; /* white */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not touch those generic variables as they may impact extensions styling. We should aim at something specific for the vim mode.

Looking at the DOM, when the VIM mode is activated the cm-fat-cursor is added to CodeMirror cm-s-jupyter CodeMirror-wrap in the top container.

I tried to add that CSS rule and it works as expected - feel free to tune the styling change this is more to point out a good CSS selector to fix the issue:

.cm-fat-cursor .cm-overlay.cm-searching {
	opacity: 0.5;
}

@fcollonval
Copy link
Member

Thanks @Jessie-Newman I have a recommendation to fix this using a slightly different and more specific change.

@fcollonval fcollonval added the bug label May 6, 2022
@fcollonval fcollonval modified the milestones: 4.0, 3.4.x May 13, 2022
@fcollonval fcollonval merged commit 5c04fa6 into jupyterlab:master May 13, 2022
@fcollonval
Copy link
Member

@meeseeksdev please backport to 3.4.x

@github-actions
Copy link
Contributor

Benchmark report

The execution time (in milliseconds) are grouped by test file, test type and browser.
For each case, the following values are computed: min <- [1st quartile - median - 3rd quartile] -> max.

The mean relative comparison is computed with 95% confidence.

Results table
Test file large_code_notebook large_md_notebook
open
chromium
actual 15167 <- [16696 - 17487 - 19023] -> 26034 2639 <- [2924 - 3069 - 3206] -> 6072
expected 13890 <- [15443 - 16091 - 16616] -> 17933 2598 <- [2852 - 2982 - 3134] -> 5115
Mean relative change 12.4% ± 2.6% 3.3% ± 3.4%
switch-from
chromium
actual 632 <- [689 - 715 - 757] -> 972 436 <- [486 - 502 - 534] -> 735
expected 576 <- [647 - 670 - 695] -> 818 431 <- [474 - 490 - 505] -> 704
Mean relative change 8.5% ± 2.3% 6.6% ± 3.0%
switch-to
chromium
actual 389 <- [476 - 495 - 510] -> 652 277 <- [314 - 325 - 338] -> 409
expected 370 <- [437 - 474 - 492] -> 556 273 <- [309 - 319 - 330] -> 385
Mean relative change 6.3% ± 2.3% 2.3% ± 1.8%
close
chromium
actual 695 <- [1145 - 1168 - 1207] -> 1366 494 <- [529 - 544 - 561] -> 1105
expected 1050 <- [1130 - 1151 - 1176] -> 1377 474 <- [511 - 529 - 545] -> 1100
Mean relative change 1.8% ± 1.5% 3.8% ± 3.4%

Changes are computed with expected as reference.

fcollonval pushed a commit that referenced this pull request May 15, 2022
…isible in vim mode (#12579)

Co-authored-by: Jessie Newman <Jessie-Newman@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Design System CSS pkg:codemirror tag:CSS For general CSS related issues and pecadilloes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vim cursor not visible on search highlights

2 participants