-
Notifications
You must be signed in to change notification settings - Fork 37.4k
fix(debug): support C# stack trace format in debug console links #281536
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
fix(debug): support C# stack trace format in debug console links #281536
Conversation
- Add support for ':line 123' format in addition to ':123:45' format - Only set selection when line number is greater than 0 - Ensure column defaults to 1 when not specified Fixes file navigation in debug console for C# stack traces. Stack traces like 'Program.cs:line 6' now correctly navigate to line 6 instead of line 1.
|
@microsoft-github-policy-service agree |
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 adds support for C# stack trace format (:line 123) in the debug console link detector, enabling proper navigation to specific line numbers when clicking on C# stack traces. The implementation maintains backward compatibility with existing formats (:123, :123:45) while also fixing a pre-existing bug where column numbers would evaluate to NaN when not specified.
Key Changes
- Extended regex patterns to recognize both
:line 123and traditional:123:45formats - Fixed column number handling to default to 1 instead of
NaNwhen column is not specified - Added validation to only set editor selection when line number is greater than 0
| const POSIX_PATH = /((?:\~|\.+)?(?:\/[\w\.-]*)+)/; | ||
| const LINE_COLUMN = /(?:\:([\d]+))?(?:\:([\d]+))?/; | ||
| // Support both ":line 123" and ":123:45" formats for line/column numbers | ||
| const LINE_COLUMN = /(?::(?:line\s+)?([\d]+))?(?::([\d]+))?/; |
Copilot
AI
Dec 5, 2025
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.
Missing test coverage for the new :line 123 format. The existing tests only cover the :123:45 format. Consider adding tests for:
file.cs:line 6(C# stack trace format)file.cs:line 6:10(C# format with column)- Mixed scenarios to ensure backward compatibility
- Add test for ':line 6' format - Add test for ':line 6:10' format with column - Add test for mixed stack trace formats - All tests passing (19/19)
|
Hm, looks like these tests fail on Windows: |
The test was failing on Windows because the regex only matched Unix-style forward slashes (/). Added platform-specific regex patterns to handle both Windows backslashes (\) and Unix forward slashes (/). Fixes the failing Windows tests in PR microsoft#281536.
Head branch was pushed to by a user without write access
466966d
connor4312
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.
thanks!
Problem
When clicking on C# stack trace links in the Debug Console (e.g.,
Program.cs:line 6), VSCode only opens the file at line 1 instead of navigating to the specific line number.Root Cause
The link detector's regex pattern didn't support the
:line 123format commonly used in C# stack traces.Solution
LINE_COLUMNregex to support both:line 123and:123:45formatscreatePathLinkto only set selection when line number > 0Testing
Related Issue
Fixes navigation in debug console for stack traces across all languages that use the
:line Nformat.