Skip to content

Conversation

@vijayupadya
Copy link
Contributor

Fixes microsoft/vscode#272505

When clicking on method references like TextModel.undo() in chat responses, the linkifier was navigating to the beginning of the class definition (TextModel) instead of navigating to the method definition (undo method within the TextModel class).

The fix is applied at two levels:

For markdown links : Prioritize the last part (method name) over the first part (class name) when matching flat symbols, using a matchCount scoring system (2 for method, 1 for class).

For inline code: First locate the class definition, then perform a recursive search within that file to find the specific method definition.

Both approaches gracefully fall back to navigating to the class definition if the method cannot be found.

@vijayupadya vijayupadya requested review from Copilot and mjbvz October 25, 2025 00:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes linkifier navigation for qualified method names (e.g., TextModel.undo()) to navigate directly to the method definition instead of stopping at the class definition. The fix implements a two-level approach: markdown links use a matchCount scoring system to prioritize method names over class names, while inline code performs recursive symbol search within the class file to locate the specific method.

Key Changes:

  • Enhanced symbol matching to prioritize the last part (method) over the first part (class) in qualified names using a matchCount scoring system (2 for method, 1 for class)
  • Added runtime method resolution that recursively searches within the class definition file to find the specific method
  • Both approaches gracefully fall back to the class definition if the method cannot be located

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/extension/linkify/vscode-node/inlineCodeSymbolLinkifier.ts Passes symbolText to resolveSymbolFromReferences for qualified name resolution
src/extension/linkify/vscode-node/findWord.ts Refactored symbol extraction to handle qualified names by searching for class first, then relying on click-time method resolution
src/extension/linkify/vscode-node/findSymbol.ts Implements matchCount scoring to prioritize last part (method) over first part (class) in flat symbol matches
src/extension/linkify/vscode-node/commands.ts Adds findMethodInSymbols helper and enhances resolveSymbolFromReferences to perform recursive method search within class files
src/extension/linkify/test/vscode-node/findSymbol.test.ts Adds comprehensive test coverage for qualified name matching including flat/hierarchical symbols and Python naming conventions

Copy link
Contributor

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

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

I wonder if we can come up with a more generic approach? Specifically talking about methods and hardcoded to look for last symbol doesn't feel right

I think you could say that symbols that are more right in the text should have higher priority, which would then work even if the last symbol isn't a match

@vijayupadya
Copy link
Contributor Author

I wonder if we can come up with a more generic approach? Specifically talking about methods and hardcoded to look for last symbol doesn't feel right

I think you could say that symbols that are more right in the text should have higher priority, which would then work even if the last symbol isn't a match

Makes sense. Updated.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat linkifier can't handle ClassName.methodName invocations and points to just class name

3 participants