Sort JSDoc @param completions by argument position#63306
Closed
Vi-Ku wants to merge 1 commit intomicrosoft:mainfrom
Closed
Sort JSDoc @param completions by argument position#63306Vi-Ku wants to merge 1 commit intomicrosoft:mainfrom
Vi-Ku wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…0183) Previously, all JSDoc @param completion entries used the same sortText value, causing editors to sort them alphabetically by name rather than by their position in the function signature. This fix sets sortText to LocationPriority + parameterIndex so that completions appear in declaration order (e.g., for function foo(z, a), 'z' appears before 'a').
Member
|
This repo is closed except for critical bugfixes, see https://github.com/microsoft/TypeScript?tab=readme-ov-file#contribute https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#note https://redirect.github.com/microsoft/TypeScript/issues/62963#issuecomment-4100336368 |
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.
Fixes #20183
Problem
When writing JSDoc
@paramtags, the completions for parameter names are sorted alphabetically instead of by their position in the function signature.For example, given:
Triggering completions at
|returnsabeforez, because both entries have the samesortTextvalue ("11"/LocationPriority), causing the editor to fall back to alphabetical sorting.Fix
Set
sortTextfor each JSDoc@paramcompletion toLocationPriority + parameterIndex(e.g.,"110","111","112"). This ensures completions appear in the same order as the function's parameter list.Changes:
src/services/completions.ts: UpdatedgetJSDocParameterCompletionsto use parameter index insortTextfor both named and destructuring parameterssrc/services/jsDoc.ts: UpdatedgetJSDocParameterNameCompletionsto use parameter index insortTextsortTextvaluesjsdocParameterNameSortOrder.tsthat explicitly verifies the sort order