-
Couldn't load subscription status.
- Fork 1.3k
Update linkifier to navigate to correct method in qualified names #1604
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 our terms of service and privacy 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
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.
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 |
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.
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. |
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.