fix(completions): sort JSDoc @param suggestions by declaration order#63439
Open
creazyfrog wants to merge 1 commit intomicrosoft:mainfrom
Open
fix(completions): sort JSDoc @param suggestions by declaration order#63439creazyfrog wants to merge 1 commit intomicrosoft:mainfrom
creazyfrog wants to merge 1 commit intomicrosoft:mainfrom
Conversation
When triggering completions after `@param` in a JSDoc comment, all
parameter suggestions were assigned the same sortText ("11"), causing
them to be ordered alphabetically by name rather than by their position
in the function signature.
For example, `function foo(z, a)` would suggest `a` before `z`.
Fix: expose the parameter index from the `mapDefined` callback and
compose a unique sortText per parameter:
sortText = SortText.LocationPriority + paramIndex.padStart(4, "0")
This produces "110000", "110001", … so parameters are sorted by their
declaration order while still being grouped within the same priority
tier as other location-priority completions. The fix applies to both
named parameters and destructuring parameters.
Fixes microsoft#20183
Signed-off-by: creazyfrog <rohitcse.gec@gmail.com>
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.
Summary
Fixes #20183
Problem
When triggering completions after
@paramin a JSDoc comment, all parameter suggestions had the samesortText: "11"(SortText.LocationPriority). This caused them to be sorted alphabetically by name rather than by their declaration order in the function signature.Fix
Expose the parameter index
ifrom themapDefinedcallback and build a per-parametersortTextthat encodes declaration position:This produces
"110000","110001", … — parameters stay within the same priority tier ("11"prefix) but are now ordered by their position in the function signature. The fix applies to both named parameters and destructuring parameters.