Deprioritize native Function methods in IntelliSense#63147
Open
apoorvdarshan wants to merge 1 commit intomicrosoft:mainfrom
Open
Deprioritize native Function methods in IntelliSense#63147apoorvdarshan wants to merge 1 commit intomicrosoft:mainfrom
apoorvdarshan wants to merge 1 commit intomicrosoft:mainfrom
Conversation
When autocompleting on a function value with custom properties, native Function prototype methods (apply, bind, call, etc.) now sort below custom properties. This is achieved by assigning SortText.SortBelow(LocationPriority) to members of the global Function, CallableFunction, and NewableFunction interfaces. Fixes microsoft#61426
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the IntelliSense experience for function values with custom properties by deprioritizing native Function prototype methods (like apply, bind, call, toString, length, arguments, caller, and prototype) so they appear below custom properties in autocomplete suggestions. This addresses issue #61426, which was raised in the context of Bun's APIs where functions like Bun.inspect have custom properties (e.g., Bun.inspect.table and Bun.inspect.custom) that are more useful than the native Function methods.
Changes:
- Added an
isNativeFunctionMemberhelper function that identifies symbols from the globalFunction,CallableFunction, andNewableFunctioninterfaces - Applied deprioritization using
SortText.SortBelow(LocationPriority)in both checked (TypeScript) and unchecked (JavaScript) completion code paths - Added comprehensive fourslash test
completionsFunctionCustomProperties.tsverifying the new behavior - Updated test infrastructure and baselines to reflect the new sort order
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/services/completions.ts |
Added isNativeFunctionMember helper and applied deprioritization logic in both checked and unchecked file completion paths |
src/harness/fourslashInterfaceImpl.ts |
Updated test infrastructure to reflect deprioritized sort text for function members and prototype |
tests/cases/fourslash/completionsFunctionCustomProperties.ts |
New test verifying custom properties sort above native Function methods while static class members maintain their priority |
tests/cases/fourslash/server/completions02.ts |
Updated to reflect new sort order with prototype and custom properties appearing before deprioritized Function methods |
tests/cases/fourslash/javaScriptPrototype1.ts |
Updated expected sortText for native Function members |
tests/cases/fourslash/completionListStaticProtectedMembers2.ts |
Simplified test using functionMembersPlus helper instead of listing individual Function members |
tests/cases/fourslash/completionListOnAliases2.ts |
Updated expected sortText for call method |
tests/baselines/reference/tsserver/fourslashServer/completions02.js |
Baseline showing correct sort order: custom properties and prototype first (sortText "11"), then Function methods (sortText "111") |
tests/baselines/reference/completionsCommitCharactersAfterDot.baseline |
Updated baselines reflecting deprioritized Function members with sortText "111" |
tests/baselines/reference/completionsCommentsClassMembers.baseline |
Updated baselines showing prototype appearing before Function methods in completion lists |
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
Bun.inspect.), nativeFunctionprototype methods (apply,bind,call, etc.) now sort below custom properties instead of above themisNativeFunctionMemberhelper that identifies symbols from the globalFunction,CallableFunction, andNewableFunctioninterfaces, and assigns themSortText.SortBelow(LocationPriority)so custom properties appear firstFixes #61426
Test plan
completionsFunctionCustomProperties.tsverifying custom properties sort above native Function methods