- Notifications
You must be signed in to change notification settings - Fork768
Fix references code lens to include imports as references#2368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
When finding references for an exported symbol, the import specifier(e.g., `abc` in `import { abc } from "./abc"`) should be counted asa reference to the export. This change:1. Adds the import location as a reference to the export symbol in searchForImportsOfExport for non-aliased imports.2. Skips duplicate addition of import specifiers when the search is coming from an export context, since they're already added by the explicit addRef call.Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
jakebailey left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot whatever you add, make sure it actually has a basis in the original implementation, and not something made up
| // === findAllReferences === | ||
| // === /myproject/a/index.ts === | ||
| // import { [|B|] } from "../b/lib"; | ||
| // import { [|[|B|]|] } from "../b/lib"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot this range is being doubled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Fixed inaaefcb7 - reverted the changes that caused the doubled ranges.
| -// import {Foo} from './foo' | ||
| +// import {[|Foo|]} from './foo' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot this is regressing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Fixed inaaefcb7 - reverted the changes that caused the regression.
| -// import { Interface } from "./def"; | ||
| -// const c: I/*GOTO IMPL*/nterface = [|{ P: 2 }|]; | ||
| +// <|import { [|Interface|] } from "./def";|> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot this is regressing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Fixed inaaefcb7 - reverted the changes that caused the regression.
The previous fix was adding imports to singleReferences and addingskip logic in getReferencesAtLocation, but this approach was notbased on the original TypeScript implementation and caused:- Doubled reference ranges like [|[|B|]|]- Regressions in goToImplementation testsThis reverts to the original behavior while keeping the fourslashtest that demonstrates the issue (showing 0 references for now).Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Reverted the incorrect fix in commitaaefcb7. The test is kept to demonstrate the issue, but the baseline now shows the current behavior (0 references). A proper fix requires more careful analysis of how TypeScript handles |
Uh oh!
There was an error while loading.Please reload this page.
Status
The fourslash test
codeLensReferencesIncludeImports_test.gois kept to demonstrate the issue. The baseline shows0 referenceswhich is the current (incorrect) behavior.A proper fix requires more careful analysis of how TypeScript handles the difference between
isDefinitionmarking vs Go's per-entry declaration filtering.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.