-
Notifications
You must be signed in to change notification settings - Fork 138
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
Fixes for lsp-ui-doc-glance #711
Fixes for lsp-ui-doc-glance #711
Conversation
The async route is recommended since the sync call will hang Emacs if the request takes too much time. Can you test with |
OK, so rather than make
I use TTY emacs, where neither childframe nor webkit work. Does the overlay version even have the concept of focus? (I can't work out how to set the focus there if it does) |
I think they serve different purpose with glance as a asynchronous version of
The overlay seems doesn't support focus so I'm not sure how to test on that as well. Can you test with GUI Emacs instead? |
I do not agree -- the only difference AFAIK between I have experimented some more using the code at current master (370022b), putting some message statements into when When using inline display (TTY), the first time glance is invoked upon starting emacs, it auto hides when expected (although the hide frame function is called immediately, it does not proceed past the condition). But from then on, it triggers auto hide immediately (when When using childframe (GUI), the auto hiding seems to work every time. This suggests that the condition in: However, in terms of testing the focus behaviour with childframe (still on master), I'm not sure how you are normally supposed to get focus into the docs from I did find another couple of bugs when using childframe (they might need testing in a minimal emacs environment):
|
b771576
to
6612828
Compare
I think the difference here is that the
The new fix is to reset the overlay, which can be a perf problem since we have to recreate a new overlay every time.
I bind The problem with the mouse pointer in the area where the child frame is to appear happens for me as well, I guess that's one of the quirks of mixing mouse + keyboard input with child frame. |
@kiennq yeah, that PR is really old and stale, but it still makes sense, feel free to re-try from master |
I had actually missed your proposed fix before I made mine. I think it's speculation as to whether there is any performance difference either way (moving an overlay may be more expensive in some cases than creating a new one), but took your suggestion anyway, as it allowed a couple of other small tidy-ups. I also went back to part of my first version in making |
Thank you @Lenbok for working on addressing the comments. Can we bind the |
I really don't like that idea. I think it is significantly clearer with the code the way it is here (just look at all the shenanigans If you want to make |
It's already async before this PR. |
Let's reword that. They are both asynchronous under the hood (that's what (Whereas mouse and cursor hovers can appear while the user is generally moving/mousing around and is likely to continue moving/mousing. It's a totally different use case and makes sense for those to be a different code path). |
On the other hand, the part about showing documentation immediately can be solved by binding |
We don't want it to be interrupted by input - if the user has initiated either of these two functions they expect to get the result back right then and aren't planning on doing anything else in the interim. In my experience showing the doc takes no appreciable time. If they change their mind, there is |
I don't agree with this. If you think the new behavior is better, please make a new PR for that while keeping the minimal fix for this problem. |
1ebf123
to
adf7f37
Compare
Separate PR created from the first commit on this branch. |
@kiennq Please re-review this PR. PR description at the top has been updated. This new strategy addresses several interrelated issues, meaning it now makes sense to keep in a single PR. Previous review comments are addressed:
(It does not address the other possible performance issue we discovered related to inline + I have tested inline and childframe docs every way I can think of and have not found anything undesirable. |
@kiennq would you (or anyone else) be able to review? |
Anyone able to review? |
I've tested it and it seems to work as expected. Sorry for the delay but lsp-ui can be really annoying with bugs... |
Thanks @brotzeit ! |
This PR seems to break the auto dismiss of the doc frame after it has been focused in (for scrolling and reading on the docs) and out. As you can see, it's broken and I have to press Tab twice for the focus to be moved to the doc frame. |
Sorry... That's the reason why I'm so hesitant to merge pull requests. I'm always missing something when I'm testing changes. |
Basically lsp-ui-doc-glance was not behaving as expected, mostly due to a bunch of interacting edge cases.
For example: When using inline docs,
lsp-ui-doc--glance-hide-frame
was conditioned on(overlayp lsp-ui-doc--inline-ov)
, however due to overlay re-use that test always succeeds after the first doc is shown. So, whenlsp-ui-doc-glance
was used for a second time (or actually after any lsp-ui-doc had been shown previously), the post-command-hook was getting cleared before the document had even been displayed (since the request was sent asynchronously, but the post-command-hook executes right afterlsp-ui-doc-glance
returns).For example:
lsp-ui-doc--glance-hide-frame
was only activated when the doc is visible. When you keyboard-quit the doc would hide without this being triggered, leaving the function hanging around on post-command-hook ready to nuke the next doc (whether that was invoked vialsp-ui-doc-show
or mouse or cursor hover). (childframe and webkit only, but only due to the first bug above)For example: invoking
lsp-ui-doc-glance
followed bylsp-ui-doc-show
would hide the doc (childframe and webkit only, but only due to the first bug above)I suspect also bugs related to unfocus frame when mixing glance vs show due to unfocus timer handling not being consistent across the both.
This PR:
lsp-ui-doc-show
asynchronous, preventing emacs blocking.lsp-ui-doc-glance
equivalent to callinglsp-ui-doc-show
plus asking for the doc to hide on the next command, meaninglsp-ui-doc-glance
now appears immediately rather than having to wait forlsp-ui-doc-delay
first.lsp-ui-doc--hide-frame
so it affects all display methods, not just glance.Fixes #713
Fixes #695