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.
- 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)
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.

4 participants