|
3 | 3 | import * as vscode from 'vscode'; |
4 | 4 | import * as path from 'path'; |
5 | 5 | import * as fs from 'fs'; |
| 6 | +import * as jsonc from 'jsonc-parser'; |
6 | 7 |
|
7 | 8 | /** |
8 | 9 | * Interface for configuration management operations |
@@ -43,11 +44,8 @@ export class DebugConfigurationManager implements IDebugConfigurationManager { |
43 | 44 | const launchJsonDoc = await vscode.workspace.openTextDocument(launchJsonPath); |
44 | 45 | const launchJsonContent = launchJsonDoc.getText(); |
45 | 46 |
|
46 | | - // Parse the JSON (removing comments and trailing commas first) |
47 | | - let cleanJson = launchJsonContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, ''); |
48 | | - // Remove trailing commas before closing brackets/braces |
49 | | - cleanJson = cleanJson.replace(/,(\s*[}\]])/g, '$1'); |
50 | | - const launchConfig = JSON.parse(cleanJson); |
| 47 | + // Parse JSONC (JSON with comments and trailing commas) |
| 48 | + const launchConfig = jsonc.parse(launchJsonContent); |
51 | 49 |
|
52 | 50 | if (launchConfig.configurations && Array.isArray(launchConfig.configurations) && launchConfig.configurations.length > 0) { |
53 | 51 | // If a specific configuration name is provided, find it |
@@ -150,6 +148,7 @@ export class DebugConfigurationManager implements IDebugConfigurationManager { |
150 | 148 | '.tsx': 'node', |
151 | 149 | '.java': 'java', |
152 | 150 | '.cs': 'coreclr', |
| 151 | + '.csproj': 'coreclr', |
153 | 152 | '.cpp': 'cppdbg', |
154 | 153 | '.cc': 'cppdbg', |
155 | 154 | '.c': 'cppdbg', |
@@ -259,11 +258,8 @@ export class DebugConfigurationManager implements IDebugConfigurationManager { |
259 | 258 | const launchJsonDoc = await vscode.workspace.openTextDocument(launchJsonPath); |
260 | 259 | const launchJsonContent = launchJsonDoc.getText(); |
261 | 260 |
|
262 | | - // Parse the JSON (removing comments and trailing commas first) |
263 | | - let cleanJson = launchJsonContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, ''); |
264 | | - // Remove trailing commas before closing brackets/braces |
265 | | - cleanJson = cleanJson.replace(/,(\s*[}\]])/g, '$1'); |
266 | | - const launchConfig = JSON.parse(cleanJson); |
| 261 | + // Parse JSONC (JSON with comments and trailing commas) |
| 262 | + const launchConfig = jsonc.parse(launchJsonContent); |
267 | 263 |
|
268 | 264 | if (launchConfig.configurations && Array.isArray(launchConfig.configurations)) { |
269 | 265 | return launchConfig.configurations.map((config: any) => config.name || 'Unnamed Configuration'); |
|
0 commit comments