Sort JSDoc parameter suggestions by argument position#63414
Open
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Open
Sort JSDoc parameter suggestions by argument position#63414Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Fixes microsoft#20183 When triggering completions after @param in a JSDoc comment, parameter suggestions are now sorted by their position in the function signature, so 'z' from foo(z, a) appears before 'a'. Previously all parameters had the same sortText (LocationPriority), causing them to be sorted alphabetically instead of by position. Co-Authored-By: RoomWithOutRoof <[email protected]>
Collaborator
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
Member
|
Please disclaim what tool you have used to send this PR https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#use-of-ai-assistance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Good day
Summary
This PR fixes issue #20183 by sorting JSDoc parameter suggestions by their position in the function signature rather than alphabetically.
Problem
When triggering completions after
@paramin a JSDoc comment, all parameters had the samesortText(LocationPriority = "11"), causing them to be sorted alphabetically instead of by their actual position in the function.For example, in
foo(z, a):aandzboth had sortText="11", sorted alphabeticallyz(index 0) comes beforea(index 1) because "00" < "01"Solution
Modified
getJSDocParameterNameCompletionsinsrc/services/jsDoc.tsto use the parameter's array index to generate a unique sortText prefixed with its position (e.g., "00", "01", "02").Changes
src/services/jsDoc.ts: Use parameter position index for sortText instead of LocationPriorityTesting
npm run build:compilerThank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.
Warmly,
RoomWithOutRoof