Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hover tooltip can be cached to a wrong location #859

Closed
yamaton opened this issue Sep 25, 2022 · 0 comments · Fixed by #860
Closed

Hover tooltip can be cached to a wrong location #859

yamaton opened this issue Sep 25, 2022 · 0 comments · Fixed by #860
Labels
bug Something isn't working feature:hover

Comments

@yamaton
Copy link
Contributor

yamaton commented Sep 25, 2022

Description

When a mouse cursor is moving when a hover is triggered, the tooltip information can be stored to a wrong location. Here, I mean "trigger" by the initial appearance of the underline to a target token.

In this example, sin shows an incorrect tooltip that is actually from math. The data is cached so this behavior stays once it occurs.

jupyterlab-lsp hover caching

Reproduce

[Optional but recommended] Go to "Advanced Setting Editor" → "Code hover" → "Throttler delay", and set the value to 500 or more to make the reproduction easy.

Point a token with a mouse cursor, and then point another token within the delay period. Timing of Ctrl key pressing does not matter, by the way.

Discussion

I found this problem when I was preparing a PR for #362. The root of this problem is that the throttler is not always in the same page as each caller. Specifically,
this.debounced_get_hover.invoke() does not always use the same this.virtual_position as it was assigned before the call if the throttler is invoked multiple times during a period.

https://github.com/jupyter-lsp/jupyterlab-lsp/blob/master/packages/jupyterlab-lsp/src/features/hover.ts#L446

I could get around this hover problem by checking if this.debounced_get_hover.invoke() referred to the same virtual position as the one in _updateUnderlineAndTooltip. Will send a PR later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature:hover
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants