Skip to content

Conversation

Sorixelle
Copy link
Contributor

@Sorixelle Sorixelle commented Jun 16, 2020

Webkit buffers don't work in posframe windows, so the old manual frame
management is kept around for webkit support.

lsp-ui-doc-border was removed, since the internal border is now used
to pad the frame.

lsp-ui-doc-mode now signals an error if Emacs is older than version 26
or is running in the terminal, as posframe does not work under those
conditions.

Closes #331, fixes #334.

@yyoncho
Copy link
Member

yyoncho commented Jun 16, 2020

Webkit buffers don't work in posframe windows, so the old manual frame
management is kept around for webkit support.

Can you elaborate on that?

@Sorixelle
Copy link
Contributor Author

The posframe doesn't get resized correctly with the webkit xwidget in it - it just stays as a one character wide and tall block. I haven't yet been able to determine why this is. I'd like to make this work properly before we merge, however.

@Sorixelle Sorixelle marked this pull request as draft June 17, 2020 08:08
@Sorixelle
Copy link
Contributor Author

Just pushed some changes that uses posframe to manage webkit buffers. After a bit of discussion in the Gitter room, I've also made posframe a required dependency. Interested to hear the general community's thoughts in this.

@Sorixelle Sorixelle marked this pull request as ready for review June 17, 2020 16:09
Copy link
Member

@yyoncho yyoncho left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I would propose the placement of the at point to be changed to be the point at the start of the hovered symbol and to be placed in a way that it does not hide the identifier itself.

@Sorixelle
Copy link
Contributor Author

Pushed a set of changes resolving the review and the point placement.

@Sorixelle Sorixelle changed the title Use posframe library for text mode lsp-ui-doc Use posframe library for lsp-ui-doc Jun 18, 2020
@Sorixelle
Copy link
Contributor Author

@kiennq I pushed a commit that uses advice instead of adding/removing hooks. I didn't run into the issue you described in my testing, so let me know if this fixes the issue.

@brotzeit
Copy link
Member

I've tested it. Seems to work well.

@Lenbok
Copy link
Contributor

Lenbok commented Jun 21, 2020

Please don't abandon support for terminal users.

@Sorixelle
Copy link
Contributor Author

Please don't abandon support for terminal users.

From memory, terminal Emacs doesn't support creating child frames at all, so this PR isn't going to break anything that wasn't already not working in the terminal.

@Lenbok
Copy link
Contributor

Lenbok commented Jun 22, 2020

@Sorixelle Using lsp-ui from current master in a terminal I currently use lsp-ui to show doc for functions. I just checked out this PR and instead I get the message about requiring graphical mode, so this PR would definitely be a regression for me.

"Set the buffer with STRING."
(defvar lsp-ui-doc--render-string nil
"The string to render in the documentation popup.")
(defvar lsp-ui-doc--render-symbol nil
Copy link
Member

Choose a reason for hiding this comment

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

Why you need this two global variables? The original version already pass symbol and string, why need to change function signature?

Copy link
Contributor Author

@Sorixelle Sorixelle Jun 22, 2020

Choose a reason for hiding this comment

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

I needed to call lsp-ui-doc--render-buffer from the xwidget-event callback lambda to solve the problem where webkit frames would be empty the first time they popped up.

lsp-ui/lsp-ui-doc.el

Lines 651 to 658 in 61651ba

(when lsp-ui-doc-use-webkit
(define-key (current-global-map) [xwidget-event]
(lambda ()
(interactive)
(let ((xwidget-event-type (nth 1 last-input-event)))
(when (eq xwidget-event-type 'load-changed)
(lsp-ui-doc--render-buffer))

I can't just pass the parameters down to it, because it's only called when the webkit widget is first created, and since it's a lambda, it'll just capture the first values it sees, and won't update on subsequent hovers.

Copy link
Member

Choose a reason for hiding this comment

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

I needed to call lsp-ui-doc--render-buffer from the xwidget-event callback lambda to solve the problem where webkit frames would be empty the first time they popped up

Interesting. I wonder how just call lsp-ui-doc--render-buffer will resolve that problem?
From what I can see, the global vars are updated in lsp-ui-doc--display, which in turn will also call lsp-ui-doc--render-buffer.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is, lsp-ui-doc--render-buffer inserts the text directly into the webkit widget via a javascript call, so it needs to be called after both the webkit widget has been inserted, and after lsp-ui-doc.html has finished loading. That last one in particular isn't guaranteed by the time lsp-ui-doc--display has finished executing, but that 'load-changed event is fired specifically when the page has finished loading, so it's the best thing for us to use, unless there's something else I'm missing.

@yyoncho
Copy link
Member

yyoncho commented Jun 23, 2020

Are there more open issues preventing merging this PR?

@Sorixelle can you check the CI? Seems like it is using something that is already deleted.

@Sorixelle
Copy link
Contributor Author

Nothing that I can think of at the moment. Not sure what's going on with the CI - it's pointing to the wrong line number, and failing on a warning. I just moved the minor mode declaration for lsp-ui-doc-frame-mode above lsp-ui-doc-mode and that shut it up, so hopefully the CI stops complaining too.

@brotzeit
Copy link
Member

I'll merge this and take a look at the test the next days(the tests are now failing for a different reason). @Sorixelle Thanks!

@brotzeit brotzeit merged commit 1ee113c into emacs-lsp:master Jun 25, 2020
@Sorixelle Sorixelle deleted the lsp-ui-doc-posframe branch June 26, 2020 03:29
@alanz
Copy link
Contributor

alanz commented Jun 26, 2020

FYI I have reverted this in my local usage, it causes the hover window to capture focus, making editing impossible.

@Sorixelle
Copy link
Contributor Author

This isn't an issue I ran into in my testing. If you've got time, open an issue with some extra detail so we can look into it.

@seagle0128
Copy link
Contributor

Any benefit from this integration? I don't see any value here, and it introduces many bugs 😭

(mouse-wheel-frame . nil)
(no-other-frame . t)
(no-accept-focus . nil)
Copy link
Member

@kurnevsky kurnevsky Jun 29, 2020

Choose a reason for hiding this comment

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

Why was it added explicitly?

@alanz you can set it to t to fix focus captures.

Added: though it might not work...

Copy link
Member

Choose a reason for hiding this comment

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

In our original child frame implementation, we removed the no-accept-focus so we can focus into child frame to scroll the document. There is little no issue with that approach though, i.e: mouse is not suddenly set focus to other frame.
However, posframe add no-accept-focus to t explicitly, so we need to add back no-accept-focus . nil here

@kiennq
Copy link
Member

kiennq commented Jun 29, 2020

Just asking, but what's the value of your focus-follow-mouse?
Can you try to it to nil?

@seagle0128
Copy link
Contributor

seagle0128 commented Jun 29, 2020

Please revert this PR before it's ready.

@kurnevsky
Copy link
Member

Just asking, but what's the value of your focus-follow-mouse?
Can you try to it to nil?

If it's a question to me then I set it to t explicitly - I like this behavior and it fits my WM config. That's why I also add (no-accept-focus . t) to lsp-ui-doc-frame-parameters myself - I don't usually need focus there though even with this setting somehow it can take focus if I click there with mouse.

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

Successfully merging this pull request may close these issues.

documentation frame wrong size Consider switching lsp-ui-doc to posframe
8 participants