Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
Copilot wants to merge4 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/add-fourslash-test-for-references

Conversation

Copy link
Contributor

CopilotAI commentedDec 12, 2025
edited
Loading

  • Understand the issue: References code lens does not include imports as references
  • Create a fourslash test for this issue
  • Attempted fix but it caused regressions (doubled ranges, goToImplementation failures)
  • Reverted incorrect fix per reviewer feedback - changes need to be based on original TypeScript implementation

Status

The fourslash testcodeLensReferencesIncludeImports_test.go is kept to demonstrate the issue. The baseline shows0 references which is the current (incorrect) behavior.

A proper fix requires more careful analysis of how TypeScript handles the difference betweenisDefinition marking vs Go's per-entry declaration filtering.

Original prompt

This section details on the original issue you should resolve

<issue_title>References code lens does not include imports as references</issue_title>
<issue_description>For a project:

// abc.tsexportfunctionabc(){}
// other.tsimport{abc}from"./abc";

The references code lens currently shows0 references

I can understand why it's doing this but it also feels a bit unexpected. TS 6.0 includes the imports as references</issue_description>

<agent_instructions>Create a fourslash test for this, based on internal/fourslash/tests/codeLensShowOnAllFunctions_test.go, Run all tests, accept the baselines, and commit that. Then work on the issue.</agent_instructions>

Comments on the Issue (you are@copilot in this section)


💡 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.

CopilotAIand others added2 commitsDecember 12, 2025 20:58
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>
Copy link
Member

@jakebaileyjakebailey left a 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";
Copy link
Member

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

Copy link
ContributorAuthor

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.

Comment on lines 6 to 7
-// import {Foo} from './foo'
+// import {[|Foo|]} from './foo'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@copilot this is regressing

Copy link
ContributorAuthor

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.

Comment on lines 6 to 8
-// import { Interface } from "./def";
-// const c: I/*GOTO IMPL*/nterface = [|{ P: 2 }|];
+// <|import { [|Interface|] } from "./def";|>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@copilot this is regressing

Copy link
ContributorAuthor

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.

CopilotAI changed the title[WIP] Add fourslash test for references code lens including importsFix references code lens to include imports as referencesDec 12, 2025
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>
Copy link
ContributorAuthor

@copilot whatever you add, make sure it actually has a basis in the original implementation, and not something made up

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 handlesisDefinition marking vs Go's per-entry declaration filtering.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jakebaileyjakebaileyAwaiting requested review from jakebailey

At least 1 approving review is required to merge this pull request.

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

References code lens does not include imports as references

2 participants

@jakebailey

[8]ページ先頭

©2009-2025 Movatter.jp