-
Notifications
You must be signed in to change notification settings - Fork 808
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
Added constraints to ParameterInformation.label break possible use cases #640
Comments
@oblitum I see your point however what would the client have done with that information. Can you give me an example about what a client rendered in the case you described. A client is not able to reconstruct a signature from the parameter info since it usually doesn't know what parameter separators to use. |
@dbaeumer I've given an example in the image above. With both offsets over short signatures and detailed parameters, clients can do that.
Alternatively:
These are just a few use cases, I imagine detailed parameters being used in other ways. |
I am still unsure I understand this since I am not sure what you propose a client should render. Do you propose that clients show both the short and the long form? The current protocol already allows showing detailed information for the active parameter since clients are supposed to call signature help after each key stroke when in this mode. So the label of the
The information in the |
Yes and No. On the examples above the client will have opportunity to chose to show both, and this can be at user's option, if it wishes to see detailed parameter info (this due to detailed per parameter info), client is able to provide a setting for that, and show two menus or one with composed result or some other idea, otherwise user could simple be content with the short prototype with (short) current parameter highlighted (this due to the offset information).
Yes, but then this form will have to be hardcoded server side and it is unable to provide the former suggestion:
The proposed idea is to remove the new constraint that Formerly it was possible to do this, because it was just an unconstrained string without any implied relation to highlighting over the signature. It was just |
Point taken. However I would like to see clients using this information (or at least having a UI for this) before we start adding this to the protocol. The original intention of the label of the |
I am not saying it is a strange idea and I am not against such a feature. All I am saying is that the field was used different by clients so far and we tried to specify this better. This is why I marked it as a feature request after understanding your idea. |
My intention with the question was not to mean you viewed it as strange, just that it's simply not a strange usage, and that given that I don't see how a specific usage have been implied before, unknown client implementations could be already doing it. Hence I asked as "serious question" whether specific application has been disclosed elsewhere before, or whether it was just an internal Microsoft view that has never been disclosed until now. |
In this view, it's not solely feature request, since it's removing something that has never been disallowed. So much so that the original string |
The LSP spec is not perfect and has holes. If we detect an under specified part we usually tighten the spec even if it breaks some unintended use cases. However we are open to add these use cases back if they do make sense in the intention of the spec. Usually a signature help info include the argument names. In your example I changed the sentence to this to make this more clear:
|
OK. I don't mean to offend, but this change breaks the previous possible user interpretations of this field badly, in my opinion it has ended up misnamed now, |
I am open for renaming it when we add additional use cases for this. As said earlier if the spec is underspecified we usually try to tighten it not to add additional unintended use cases. The current change is to clarify this. Do you have a better wording to do so? |
Better wording for what |
Actually, you made realize of the |
FWIW, I'm modifying the proposal for that, just to register it correctly. |
This is a breaking change which I usually try to avoid. My current goal is to clarify the current intended behavior around signature help requests and to support cases were the parameter label is not unique without breaking any existing clients or servers (this is why I changed must to should :-)). If we want to support other use cases we need to think about whether we can fit it into the current request or whether we need to think about a new request clients and servers can opt into. |
Ignore my last comment. I misread your latest proposal which is not breaking. However my primary goal is still to clarifying the current intended behavior. |
That's the issue, the (now rewritten) proposal is clearer at that than what has been done. "label" generally conveys a label, but now, in this specific place it's meant to mean a range over another piece of text. Change while it's early! :) |
FWIW, I can see it from the frame of mind of hierarchical label (signature) and (sub)labels (parameter), as it seems is what is desired to attain (albeit limiting). It was just not my frame of mind at first, and probably isn't for many other developers too, given the generic names employed, |
I totally agree naming this label was a bad choice and highlight would have been the better name. But if not absolutely necessary we try to clarify things and not change intention or to break. I am absolutely open to extend this to allow unconstrained labels that can be presented in the UI as well. |
I could suggest |
Even if we split this up the label would be specified to be a sub label to highlight a portion in the signature label. To make it clearer that its intended use case is being such a highlight I thought it is better to have one property instead of two. |
I think it's revolving back to original problems. Anyway, thanks for hearing my thoughts, ¯\_(ツ)_/¯. |
Added Go language example. |
@oblitum's proposal looks good to me.
As a server and client developer who has also watched many other implementations, I'd say yes. Breaking sooner than later just causes less pain. Really few people have noticed the Dec 13 change given that there is still a typo describing the newly added
Another thing worth clarifying is do the offsets specify Unicode code points, or UTF-16 code units? This may hardly matter in practice, though. (I hope it cares APL, C++, Haskell and some others)
As a non-native English speaker this intimidates me :( I hope this issue can be addressed soon. The vey few client-side developers who have observed this feature are still sitting on the fence. |
@MaskRay thanks for pointing out the wrong mentioning in the change log. I fixed that. Just to clarify my thinking here:
If we add an un-constraint label and no client does something with it then we don't win anything. So my proposal would be to have a client capability Having these capability flags is how we moved the protocol forward so far and I would like to keep it that way. I will clarify the offset thing. It is the same definition as with all positions and ranges. Thanks for pointing this out. |
I don't understand this since I state in the proposal:
3854f1c is the first place I see the constraint over the |
I'll declare what for me this looks like. The protocol was general on that (as stated repeatedly, the word "label" and the type string is not in favor of the field to be constrained/viewed as highlighting), Microsoft started to have that interpretation in their tools, then thought to add it without community feedback. The lack of RFC process for a protocol makes me very sad about language server protocol. |
As I've demonstrated previously, I'm here more for fixing than adding a feature I wish. If it's to insert |
@oblitum I can see why you think that way but this is not what is happening. The LSP protocol started as a VS Code only protocol and then the community saw the usefulness of it and ask us to move it to a more public space. Due to this some parts are under specified or with the knowledge of today would have been better specified differently. This being said the first goal if things are under specified is to make clear what the original intention was. Reason is that we want to make sure new clients implement this behavior and servers can rely on a certain behavior. In this specific use case it is about being able to highlight the active parameter in the signature. This got clarified by the comment to make sure clients and server understand the original intend. Since a string is a bad idea and is not sufficient we added the [number, number] however it is control by a flag. A server is not allowed to use [number, number] unless a client allows it. Based on your comments (to not break clients that use the label differently) I made the containment a should and not a must (2 days ago commit: 335dd85) but made it even clearer what the intention is. I used this approach for all specification clarification so far and as said I try to balance the different aspects as good as I can. Believe me if I could start this in a green field I would do it differently. |
This is statement alone give me chills. It translates to me as: unknown changes can be added anytime (we never know when a new under specified thing with unknown original intentions will come up), outsiders can't do nothing against that. |
Beyond the Unicode and Emoji those programming languages allow, couldn't LSP be minimally usable for natural languages too? Does it have to make life difficult for clients/servers that wish to provide not only programming language completion/highlighting but also simple textual completion/highlighting unified in a single protocol without have to battle with LSP mix of @MaskRay thanks for your input. related #376 This is a bit off-topic theme in this issue, so, just a complement. |
Beyond adding support for inclusive start and exclusive end offsets to spec, commit 3854f1c added additional constraints to
ParameterInformation.label
when in string form, which can preclude neat functionality for users:For example, before, compliant client and servers could take advantage of not having such limitation to provide terser prototype form on
SignatureInformation.label
, while providing full parameter types on eachParameterInformation.label
. Types can be rather long, so having full form just for active parameter that clients can pick fromparameters
, while having short form of the rest (fromSignatureInformation.label
), can provide ideal UX and better language support (see Go example bellow).Beyond that, the current addition require clients to inform the capability of reading labels as offsets (otherwise it could potentially break clients), while the following doesn't need it.
Proposal
To solve this, while still have the added constraints available, I think the best protocol would not change
ParameterInformation.label
fromstring
tostring | [number, number]
(making alabel
work as label or as highlighting), but instead add a specific field to convey a highlight overSignatureInformation.label
:This keep intentions for fields (
ParameterInformation
) and sub-fields (label
) clear, while nor the previous or the current state is clear at all. And also gives room for the potential use-cases referred in this thread, which could in fact be in use already.In this proposal
label
just means to be a textual label, as it could have always been interpreted before. It is not to mean label whose job is highlighting, but when in string form (which is the usual form of labels) is unable to do that job correctly (1. there could be multiple matches,int
matches in 3 places in theint foo(int, int)
signature; 2. it's misnamed "label").highlight
is a proper highlight (correctly named), and not an option tostring
, so that it can do its job correctly as a properly indexed[number, number]
sub-string view, and never fail at that (no multiple matches).This is nice because beyond adding an always correct highlighting, the text for
label
is free from being identical to the highlight, to keep doing its job as a simple label on its own. It can't also break clients. There's no need to announce capability.Better language support
For example, with this proposal we could have for Go a
foo(a, b: int) -> int
signature label, with non matchinga: int
andb: int
parameter labels (or simplyint
for each), with highlight ona
orb
in the signature. It's impossible to do that with the current state.The text was updated successfully, but these errors were encountered: