Skip to content

Conversation

@odinGitGmail
Copy link

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 123 format commonly used in C# stack traces.

Solution

  1. Updated LINE_COLUMN regex to support both :line 123 and :123:45 formats
  2. Modified createPathLink to only set selection when line number > 0
  3. Ensured column defaults to 1 when not specified

Testing

  • ✅ Code formatting passes (hygiene check)
  • ⚠️ Local testing was blocked by build environment issues
  • Recommend CI/CD testing by the VSCode team

Related Issue

Fixes navigation in debug console for stack traces across all languages that use the :line N format.

- 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.
@odinGitGmail
Copy link
Author

@microsoft-github-policy-service agree

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 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 123 and traditional :123:45 formats
  • Fixed column number handling to default to 1 instead of NaN when 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]+))?/;
Copy link

Copilot AI Dec 5, 2025

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:

  1. file.cs:line 6 (C# stack trace format)
  2. file.cs:line 6:10 (C# format with column)
  3. Mixed scenarios to ensure backward compatibility

Copilot uses AI. Check for mistakes.
odinGitGmail and others added 2 commits December 6, 2025 11:06
- 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
connor4312 previously approved these changes Dec 13, 2025
@connor4312 connor4312 enabled auto-merge (squash) December 13, 2025 00:03
@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Dec 13, 2025
dmitrivMS
dmitrivMS previously approved these changes Dec 13, 2025
@connor4312
Copy link
Member

Hm, looks like these tests fail on Windows:


  1) Debug - Link Detector
       mixedStackTraceFormats:

      
      + expected - actual

      -false
      +true
      
  AssertionError: false == true
  	at Context.<anonymous> (http://localhost:58316/c1bccc748c2f775b6f519880fdd91232/out/vs/workbench/contrib/debug/test/browser/linkDetector.test.js:222:5)



2025-12-13T00:07:57.284Z pw:browser [pid=6476] <gracefully close start>
2025-12-13T00:07:57.314Z pw:browser [pid=6476] <process did exit: exitCode=0, signal=null>
2025-12-13T00:07:57.314Z pw:browser [pid=6476] starting temporary directories cleanup
2025-12-13T00:07:57.321Z pw:browser [pid=6476] finished temporary directories cleanup
2025-12-13T00:07:57.321Z pw:browser [pid=6476] <gracefully close end>
The followings tests are failing:
 - Debug - Link Detector mixedStackTraceFormats (reason: false == true)

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

@odinGitGmail odinGitGmail dismissed stale reviews from dmitrivMS and connor4312 via 466966d December 13, 2025 02:21
@connor4312 connor4312 enabled auto-merge December 13, 2025 17:37
Copy link
Member

@connor4312 connor4312 left a comment

Choose a reason for hiding this comment

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

thanks!

@connor4312 connor4312 merged commit f6a851a into microsoft:main Dec 13, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants