diff --git a/package-lock.json b/package-lock.json index 9558bd8..4017cdc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,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": { @@ -499,7 +500,6 @@ "integrity": "sha512-IgSWvLobTDOjnaxAfDTIHaECbkNlAlKv2j5SjpB2v7QHKv1FIfjwMy8FsDbVfDX/KjmCmYICcw7uGaXLhtsLNg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.56.0", "@typescript-eslint/types": "8.56.0", @@ -758,7 +758,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -1517,7 +1516,6 @@ "integrity": "sha512-20MV9SUdeN6Jd84xESsKhRly+/vxI+hwvpBMA93s+9dAcjdCuCojn4IqUGS3lvVaqjVYGYHSRMCpeFtF2rQYxQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -1748,7 +1746,6 @@ "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", "license": "MIT", - "peer": true, "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", @@ -2153,7 +2150,6 @@ "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.5.tgz", "integrity": "sha512-3qq+FUBtlTHhtYxbxheZgY8NIFnkkC/MR8u5TTsr7YZ3wixryQ3cCwn3iZbg8p8B88iDBBAYSfZDS75t8MN7Vg==", "license": "MIT", - "peer": true, "engines": { "node": ">=16.9.0" } @@ -2514,6 +2510,12 @@ "dev": true, "license": "MIT" }, + "node_modules/jsonc-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", + "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", + "license": "MIT" + }, "node_modules/jszip": { "version": "3.10.1", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", @@ -3727,7 +3729,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -3803,7 +3804,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -4119,7 +4119,6 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/package.json b/package.json index a638ba2..d5781c8 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/debuggingExecutor.ts b/src/debuggingExecutor.ts index 47d1526..409e4e8 100644 --- a/src/debuggingExecutor.ts +++ b/src/debuggingExecutor.ts @@ -38,13 +38,6 @@ export class DebuggingExecutor implements IDebuggingExecutor { config: vscode.DebugConfiguration ): Promise { 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) { @@ -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 { - // 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; } /** diff --git a/src/utils/debugConfigurationManager.ts b/src/utils/debugConfigurationManager.ts index b57b613..967f997 100644 --- a/src/utils/debugConfigurationManager.ts +++ b/src/utils/debugConfigurationManager.ts @@ -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 @@ -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 @@ -150,6 +148,7 @@ export class DebugConfigurationManager implements IDebugConfigurationManager { '.tsx': 'node', '.java': 'java', '.cs': 'coreclr', + '.csproj': 'coreclr', '.cpp': 'cppdbg', '.cc': 'cppdbg', '.c': 'cppdbg', @@ -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');