Deprioritize native Function methods in IntelliSense#63147
Deprioritize native Function methods in IntelliSense#63147apoorvdarshan 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
|
@microsoft-github-policy-service agree |
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 |
|
With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies). Next steps for PRs:
|
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