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

lsp-ui-doc-delay also applies to lsp-ui-doc-glance/-show #728

Open
thomasheartman opened this issue Aug 8, 2022 · 6 comments
Open

lsp-ui-doc-delay also applies to lsp-ui-doc-glance/-show #728

thomasheartman opened this issue Aug 8, 2022 · 6 comments

Comments

@thomasheartman
Copy link

thomasheartman commented Aug 8, 2022

Description and expectations

The variable lsp-ui-doc-delay controls how long you need to idle before the lsp-ui-doc popup shows up. However, it also seems to affect how long it takes before the doc pops up when you explicitly trigger the doc, which is unexpected.

So for instance, if I run lsp-ui-doc-glance in a buffer, it'll only show after lsp-ui-doc-delay seconds. This seems like strange behavior. I would expect that when you manually trigger it, it'd show immediately.

Additional info

I did some digging, and I found this defun which is used by both lsp-ui-doc-glance and lsp-ui-doc-show. It should (as far as I can tell), set lsp-ui-doc-delay to 0 for the lsp-ui-doc--make-request function.

(defun lsp-ui-doc-show ()
  "Trigger display hover information popup."
  (interactive)
  (let ((lsp-ui-doc-show-with-cursor t)
        (lsp-ui-doc-delay 0))
    (lsp-ui-doc--make-request)))

I'm not very experienced at debugging elisp, but I put a message call within the lsp-ui-doc--make-request function and evaluated the defun. Whenever I invoked the lsp-ui-doc-glance function, it would tell me that lsp-ui-doc-delay was whatever it was usually set to (and definitely not 0). So for some reason, it seems that this variable doesn't apply correctly.


Do you know what's going on here? I'd be happy to share any other details if you need anything. Thank you!

System details

  • OS: macOS
  • emacs version: GNU Emacs 28.1 (build 1, aarch64-apple-darwin21.3.0, NS appkit-2113.30 Version 12.2.1 (Build 21D62))
  • lsp-ui version: a94bcec
  • lsp-mode: 5e511babdeda47552e56396dd05dfb86eaabeefd
@Lenbok
Copy link
Contributor

Lenbok commented Aug 8, 2022

Can you double check you are actually using lsp-ui version a94bcec or higher? Prior to that version I would expect the delay you are seeing, but that commit fixed the issue, and indeed it works correctly for me.

@thomasheartman
Copy link
Author

Thanks for the response 😄 As far as I can tell, I am indeed using version 494bcec or higher. At least M-x find-library lsp-ui takes me to a straight repo currently on version 8d4fa5a. I closed and reopened emacs to make sure I didn't have an older version lying around, but no dice, I'm afraid. Would you like me to double check in some other way?

@Lenbok
Copy link
Contributor

Lenbok commented Aug 9, 2022

Perhaps put a similar message inside the lets in both lsp-ui-doc-glance and lsp-ui-doc-show to trace a little more. Does directly calling lsp-ui-doc-show also exhibit the delay before the doc appears?

@thomasheartman
Copy link
Author

thomasheartman commented Aug 9, 2022

Sure thing! And yeah, calling lsp-ui-doc-show directly gives the same delay.

Logs

Here's some 'log' output. For glance and show, the log message is within their let blocks, before calling their final function. For the make-request function, I added three different log lines:

  • top: at the very top of the function, before anything else can evaluate
  • middle: before calling lsp-ui-doc--hide-frame and setting the timer
  • lambda: within the timer callback function

lsp-ui-doc-glance

lsp-ui-doc-glance | lsp-ui-doc-delay: 2
lsp-ui-doc-show | lsp-ui-doc-delay: 0
lsp-ui-doc--make-request (top) | lsp-ui-doc-delay: 0
lsp-ui-doc--make-request (middle) | lsp-ui-doc-delay: 0
lsp-ui-doc--make-request (top) | lsp-ui-doc-delay: 2
lsp-ui-doc--make-request (middle) | lsp-ui-doc-delay: 2
lsp-ui-doc--make-request (top) | lsp-ui-doc-delay: 2
lsp-ui-doc--make-request (lambda) | lsp-ui-doc-delay: 2

Interestingly, it seems as if lsp-ui-doc--make-request is called multiple times with different doc delay values.

lsp-ui-doc-show

lsp-ui-doc-show | lsp-ui-doc-delay: 0
lsp-ui-doc--make-request (top) | lsp-ui-doc-delay: 0
lsp-ui-doc--make-request (middle) | lsp-ui-doc-delay: 0
lsp-ui-doc--make-request (top) | lsp-ui-doc-delay: 2
lsp-ui-doc--make-request (middle) | lsp-ui-doc-delay: 2
lsp-ui-doc--make-request (lambda) | lsp-ui-doc-delay: 2

This seems to work the exact same as with glance, except it doesn't have the initial glance call.


From what I can make out, there is something that happens after the first request has started, which invokes make-request again with a different timeout. Presumably this also resets the popup, so it doesn't show. Does this sound familiar at all?

@Lenbok
Copy link
Contributor

Lenbok commented Aug 10, 2022

The trace suggests that the show/glance popup is getting dismissed immediately and then you are seeing a popup initiated via lsp-ui-doc-mode cursor hover (since that also triggers calls to lsp-ui-doc--make-request, but without overriding the delay). Are you using lsp-ui-doc-show-with-cursor? Try turning it and/or lsp-ui-doc-mode off.

@thomasheartman
Copy link
Author

Ah, okay, that might explain it indeed. And yeah, I am using lsp-ui-doc-show-with-cursor. Turning that off fixes the removes the delay when called directly. Thanks!

I realize I wasn't completely clear about this in my opening post, so sorry for the confusion. A bit late, but here's my use case / what I want to achieve:

  • If I idle the cursor at a symbol for n seconds (lsp-ui-doc-delay), the doc should pop up
  • If I explicitly invoke a show or glance, then the doc should pop up immediately.

In other words, I'd like to leave lsp-ui-doc-show-with-cursor on, so that the doc pops up automatically after a timeout. At the same time, I'd like to be able to invoke it explicitly and have it show up immediately.

Is that possible at the moment or is that not supported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants