Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"@modelcontextprotocol/sdk": "^1.26.0",
"@types/express": "^5.0.3",
"express": "^5.2.1",
"jsonc-parser": "^3.3.1",
"zod": "^3.25.76"
},
"devDependencies": {
Expand Down
26 changes: 1 addition & 25 deletions src/debuggingExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ export class DebuggingExecutor implements IDebuggingExecutor {
config: vscode.DebugConfiguration
): Promise<boolean> {
try {
if (config.type === 'coreclr') {
// Open the specific test file instead of the workspace folder
const testFileUri = vscode.Uri.file(config.program);
await vscode.commands.executeCommand('vscode.open', testFileUri);
vscode.commands.executeCommand('testing.debugCurrentFile');
return true;
}
const workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(workingDirectory));
return await vscode.debug.startDebugging(workspaceFolder, config);
} catch (error) {
Expand Down Expand Up @@ -344,24 +337,7 @@ export class DebuggingExecutor implements IDebuggingExecutor {
* Check if there's an active debug session that is ready for debugging operations
*/
public async hasActiveSession(): Promise<boolean> {
// Quick check first - no session at all
if (!vscode.debug.activeDebugSession) {
return false;
}

try {
// Get the current debug state and check if it has location information
// This is the most reliable way to determine if the debugger is truly ready
const debugState = await this.getCurrentDebugState();

// A session is ready when it has location info (file name and line number)
// This means the debugger has attached and we can see where we are in the code
return debugState.sessionActive && debugState.hasLocationInfo();
} catch (error) {
// Any error means session isn't ready (e.g., Python still initializing)
console.log('Session readiness check failed:', error);
return false;
}
return vscode.debug.activeDebugSession !== undefined;
}

/**
Expand Down
16 changes: 6 additions & 10 deletions src/utils/debugConfigurationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as vscode from 'vscode';
import * as path from 'path';
import * as fs from 'fs';
import * as jsonc from 'jsonc-parser';

/**
* Interface for configuration management operations
Expand Down Expand Up @@ -43,11 +44,8 @@ export class DebugConfigurationManager implements IDebugConfigurationManager {
const launchJsonDoc = await vscode.workspace.openTextDocument(launchJsonPath);
const launchJsonContent = launchJsonDoc.getText();

// Parse the JSON (removing comments and trailing commas first)
let cleanJson = launchJsonContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
// Remove trailing commas before closing brackets/braces
cleanJson = cleanJson.replace(/,(\s*[}\]])/g, '$1');
const launchConfig = JSON.parse(cleanJson);
// Parse JSONC (JSON with comments and trailing commas)
const launchConfig = jsonc.parse(launchJsonContent);

if (launchConfig.configurations && Array.isArray(launchConfig.configurations) && launchConfig.configurations.length > 0) {
// If a specific configuration name is provided, find it
Expand Down Expand Up @@ -150,6 +148,7 @@ export class DebugConfigurationManager implements IDebugConfigurationManager {
'.tsx': 'node',
'.java': 'java',
'.cs': 'coreclr',
'.csproj': 'coreclr',
'.cpp': 'cppdbg',
'.cc': 'cppdbg',
'.c': 'cppdbg',
Expand Down Expand Up @@ -259,11 +258,8 @@ export class DebugConfigurationManager implements IDebugConfigurationManager {
const launchJsonDoc = await vscode.workspace.openTextDocument(launchJsonPath);
const launchJsonContent = launchJsonDoc.getText();

// Parse the JSON (removing comments and trailing commas first)
let cleanJson = launchJsonContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
// Remove trailing commas before closing brackets/braces
cleanJson = cleanJson.replace(/,(\s*[}\]])/g, '$1');
const launchConfig = JSON.parse(cleanJson);
// Parse JSONC (JSON with comments and trailing commas)
const launchConfig = jsonc.parse(launchJsonContent);

if (launchConfig.configurations && Array.isArray(launchConfig.configurations)) {
return launchConfig.configurations.map((config: any) => config.name || 'Unnamed Configuration');
Expand Down