Skip to content

Conversation

@tzengshinfu
Copy link

Based on #714

Added options for handling errors encountered during debugging.

Change Description

Add an On Errors option to the settings (highlighted in orange in the image below).
This option checks the diagnostics list for any items with severity set to "error" before starting debugging.
If any are found, it handles them according to the selected setting.
pr-1

Options

  • debugAnyWay: Continue debugging.
  • showErrors: Show errors and stop debugging.
  • abort: Stop debugging.
  • prompt: Display a dialog box for the user to choose one of the above three actions.

Since debugAnyWay is the default value, adding this feature does not change the current debugging behavior.
pr2

Example

Take this code with a spelling error as an example.
With On Errors set to prompt,
when pressing F5 or image,
a dialog box will appear asking the user how to proceed
pr-3

When showErrors is selected (highlighted in orange in the image above), the error list will be shown and debugging will stop.
pr4

@tzengshinfu
Copy link
Author

@microsoft-github-policy-service agree

@martinMP-ai
Copy link

@microsoft-github-policy-service agree

Copilot AI review requested due to automatic review settings January 15, 2026 12:30
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 error handling options for debugging and refactors Python environment integration to support both the legacy Python extension API and a new Python Environments extension. The PR includes significant changes to how Python interpreters are resolved, terminal quote character computation, and comprehensive test updates.

Changes:

  • Added onErrors configuration option to control behavior when encountering diagnostic errors before debugging
  • Refactored Python API integration to support dual extension paths (legacy and new environments extension)
  • Added automatic terminal quote character detection based on shell type
  • Improved PATH environment variable handling to avoid double separators
  • Updated test infrastructure and added comprehensive test coverage

Reviewed changes

Copilot reviewed 70 out of 72 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/extension/common/onErrorsAction.ts New file implementing error handling actions before debugging
src/extension/extensionInit.ts Added error checking before debug commands execute
src/extension/debugger/configuration/debugConfigurationService.ts Integrated error handling and improved interpreter resolution
src/extension/common/python.ts Refactored to support both legacy and new Python environment extensions
src/extension/common/legacyPython.ts New file implementing legacy Python extension API compatibility
src/extension/envExtApi.ts New file with comprehensive Python Environments extension API types
src/extension/debugger/configuration/resolvers/base.ts Enhanced Python path resolution with better documentation
src/extension/debugger/configuration/resolvers/launch.ts Added terminal quote character computation
src/extension/noConfigDebugInit.ts Fixed PATH separator handling
package.json Added onErrors setting and terminalQuoteCharacter configuration
Multiple test files Updated tests for new API structures and added comprehensive coverage
Localization files Added translations for new error message
Build files Updated Node.js version and build configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +212 to +216
if (platform === 'win32') {
return "'"; // Default is powershell
} else {
return '"'; // Default is bash/zsh
}
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The comment on line 213 states "Default is powershell" but this assumption may not be accurate for all Windows systems. Windows 10/11 now defaults to PowerShell, but older systems or user configurations may use cmd.exe as default. Consider updating the comment to be more accurate: "Defaults to single quote (PowerShell default on modern Windows)" or add additional logic to detect the actual default shell.

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +35
{ title: 'Debug Anyway', id: OnErrorsActions.debugAnyway },
{ title: 'Show Errors', id: OnErrorsActions.showErrors },
{ title: 'Abort', id: OnErrorsActions.abort, isCloseAffordance: true },
];
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The action button titles are hardcoded English strings instead of using l10n for localization. These should be wrapped with l10n.t() for consistency with the rest of the codebase and to support multiple languages.

Copilot uses AI. Check for mistakes.
Comment on lines 104 to +110
if (err) {
traceError(`Error reading debuggerAdapterEndpoint.txt file: ${err}`);
return;
}
try {
// parse the client port
const dataParse = data.toString();
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The variable dataParse is declared after the error check but it was previously declared before (line 104 in old code). While this change improves code by only parsing when needed, the variable name could be more descriptive. Consider renaming to fileContent or endpointData for better clarity.

Copilot uses AI. Check for mistakes.
return;
}
// If program is a valid file, get interpreter for that file
if (fs.existsSync(debugConfiguration.program) && fs.statSync(debugConfiguration.program).isFile()) {
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The code calls fs.statSync() after already checking fs.existsSync(). This results in two filesystem calls. Consider using only fs.statSync() wrapped in a try-catch, as statSync will throw if the file doesn't exist, eliminating the redundant existsSync check.

Copilot uses AI. Check for mistakes.
Comment on lines +666 to +667
"format-check": "prettier --check \"src/**/*.ts\" \"build/**/*.yml\" \".github/**/*.yml\"",
"format-fix": "prettier --write \"src/**/*.ts\" \"build/**/*.yml\" \".github/**/*.yml\"",
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The quotes in the glob patterns were changed from single quotes to double quotes. While this works, it's inconsistent with the previous style and may cause issues on some shells. Consider keeping the original single quote style or documenting why the change was necessary.

Suggested change
"format-check": "prettier --check \"src/**/*.ts\" \"build/**/*.yml\" \".github/**/*.yml\"",
"format-fix": "prettier --write \"src/**/*.ts\" \"build/**/*.yml\" \".github/**/*.yml\"",
"format-check": "prettier --check 'src/**/*.ts' 'build/**/*.yml' '.github/**/*.yml'",
"format-fix": "prettier --write 'src/**/*.ts' 'build/**/*.yml' '.github/**/*.yml'",

Copilot uses AI. Check for mistakes.
}
}

const profile = defaultProfile ? profiles[defaultProfile] : profiles[0];
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

This use of variable 'defaultProfile' always evaluates to true.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants