Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Send range with textDocument/hover when possible #1900
Send range with textDocument/hover when possible #1900
Changes from 4 commits
66b0fe0
38f51c9
ffef3bc
21169c9
8bdc9bf
6df1166
7fad7cf
8107120
eb66975
7376b2c
265e422
7972cd1
5b3182a
5efa539
6a21f05
7e5e045
d95f7e5
e47c1f4
2c66b1a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I still think this is way too complicated for its own good?
I was imagining a server capability path
hoverProvider.rangeSupport
, which is a boolean, which istrue
when the server has support for a range in the request.Client side request:
hoverProvider.rangeSupport
, andparams["range"] = region_to_range(first_selection_region(view), view)
(I'm unsure if all these additional checks other than the
hoverProvider.rangeSupport
are needed. I could imagine other servers wanting to have the information about the current position in any case, whether it's contained in the range or not)Server side:
"range"
and do something clever with thatClient side response:
This whole scheme requires no more than 8 lines of diff, no? We're in a position to cook up an additional server capability and enhancement to the
textDocument/hover
request and I think the above scheme is the least intrusive for the spec.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, whether the server capability is considered experimental or not (
experimental.rangeHoverProvider
) is an implementation detail for LSP-metals I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two scenarios are missing:
lsp_hover
is invoked via keyboard and the mouse isn't hovering.textDocument/hover
should be sent with selectiontextDocument/hover
should be sent with mouse positionThis is why there are four cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, maybe I want to see both the expression type of the range as well as type info of the position outside of the range using the mouse? Why must that be excluded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes and it is possible with the current implementation. We just can't send a request with both fields set: https://scalameta.org/metals/docs/integrations/new-editor#textdocumenthover
it is not excluded but as I said there are multiple combinations and these four checks are there for that.
Are you saying you can handle all those cases with fewer checks ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still feels wrong to me and I would argue to not send the selection if it is entirely unrelated to mouse hover. Shouldn't it be a separate command which can be used to assign a key binding then? For example
lsp_selection_info
or so.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, actually the
lsp_hover
already takes the optionalpoint
argument, and as implemented here it is just extending this concept. So feel free to ignore my concern if it's useful to combine them all intolsp_hover
, even though not really related to "hover".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using the keyboard the "point" has to follow the caret. It wouldn't make sense to follow the mouse pointer when using keyboard.
Yes, the naming of
textDcoument/hover
request makes it confusing to think about in terms of keyboard usage but if we want to allow triggering the hover info from the keyboard (which we are and should) then it only makes sense to follow the caret position. It would be unusable otherwise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I think I had this confusion because I don't have this keybinding set up, and because
lsp_hover
does different things depending on how it was invoked. Should be fine then as it is!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwols I simplified it now and all cases work. Sorry for missing your point last time.