fix(debug): support C# stack trace format in debug console links#281536
Merged
connor4312 merged 4 commits intomicrosoft:mainfrom Dec 13, 2025
Merged
fix(debug): support C# stack trace format in debug console links#281536connor4312 merged 4 commits intomicrosoft:mainfrom
connor4312 merged 4 commits intomicrosoft:mainfrom
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.
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
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]+))?/; |
There was a problem hiding this comment.
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)
connor4312
previously approved these changes
Dec 13, 2025
dmitrivMS
previously approved these changes
Dec 13, 2025
Member
|
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.
auto-merge was automatically disabled
December 13, 2025 02:21
Head branch was pushed to by a user without write access
466966d
alexdima
approved these changes
Dec 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.