-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Make sortText on completions be enum-typed #36043
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
Conversation
Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @amcasey, @mjbvz, @minestarks for you. Feel free to loop in other consumers/maintainers if necessary |
declare namespace ts.Completions { | ||
export enum SortText { | ||
LocationPriority = "0", | ||
OptionalMember = "1", |
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.
Why are some "member" and others "members"?
So if VS relies on specific string-numbers for the sort text, does that mean that VS/vscode couldn't handle LS plugins that provide arbitrary alphanumeric content for the |
For reference: The angular language service plugin definitely passes full on arbitrary strings. The |
@weswigham VS code uses string sorting logic: https://github.com/microsoft/vscode/blob/9f474febfee5330f7a9a7456862ef73d0b6f0bf5/src/vs/editor/contrib/suggest/suggest.ts#L229 So you could use |
Right - all that matters is that whoever is sending the |
agree with @weswigham here.. this needs to be string so that any string value can be passed in.. Its enum in services layer internally so that it can easily be labeled instead of making them "1" or "2" |
@weswigham @sheetalkamat we don't generally care about the text - we specifically care about the My goal here is to either prevent these values from being changed or, if that's not feasible, to at least have a way to get notified when they get changed. I'd also be open to an additional property saying "this entry is a js-only guess" if that's preferred. |
I think making a property for js-only guess is better than having enum for the sorting text |
Superseded by #36063. |
We've had a couple issues in the past where the value of a member of the
SortText
enum has changed when adding a new member. This has caused bugs in editors that use TSServer.Here, we ensure that the
sortText
property of completion entries is specifically typed with theSortText
enum, so that it's properly represented in the protocol.