diff --git a/CHANGELOG.md b/CHANGELOG.md index d01e94f0..938d727d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Also want to check the development status, check the [commit history](https://gi * [#255](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/255) Objects with child elements in index notation such as `["a & -"]` may get stuck when retrieving child elements * [#256](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/256) v2 only bug. If double/single quotes are used in #Include directive, they do not appear in Loaded Scripts * [#262](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/262) If runtime is v2, it may be aborted with an error when attaching +* [#285](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/285) The `extends` attribute in launch.json does not work in the multi-root workspace and throws an error ## [1.11.0] - 2022-02-11 ### Added diff --git a/README.md b/README.md index f9b56ecf..becfcd24 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ This extension is a debugger adapter for [VSCode](https://code.visualstudio.com/ * Fixed: [#255](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/255) Objects with child elements in index notation such as `["a & -"]` may get stuck when retrieving child elements * Fixed: [#256](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/256) v2 only bug. If double/single quotes are used in #Include directive, they do not appear in Loaded Scripts * Fixed: [#262](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/262) If runtime is v2, it may be aborted with an error when attaching + * Fixed: [#285](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/285) The `extends` attribute in launch.json does not work in the multi-root workspace and throws an error * `1.11.0` - 2022-02-11 * Added: [#201](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/201) Add `useLoadedScripts` to launch.json diff --git a/package-lock.json b/package-lock.json index 9dbfdcb9..01a6a5e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "fast-glob": "^3.2.7", "fast-xml-parser": "^3.16.0", "he": "^1.2.0", + "jsonc-parser": "^3.2.0", "lazy-promise": "^4.0.0", "lodash": "^4.17.20", "matcher": "^4.0.0", @@ -5451,10 +5452,9 @@ } }, "node_modules/jsonc-parser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.0.0.tgz", - "integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==", - "dev": true + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" }, "node_modules/jsonfile": { "version": "6.1.0", @@ -11814,10 +11814,9 @@ "dev": true }, "jsonc-parser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.0.0.tgz", - "integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==", - "dev": true + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" }, "jsonfile": { "version": "6.1.0", diff --git a/package.json b/package.json index 278577f8..23e179e5 100644 --- a/package.json +++ b/package.json @@ -1491,6 +1491,7 @@ "fast-glob": "^3.2.7", "fast-xml-parser": "^3.16.0", "he": "^1.2.0", + "jsonc-parser": "^3.2.0", "lazy-promise": "^4.0.0", "lodash": "^4.17.20", "matcher": "^4.0.0", diff --git a/src/extension.ts b/src/extension.ts index cc399911..621a1565 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -2,9 +2,10 @@ /* eslint-disable @typescript-eslint/no-unsafe-argument */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable require-atomic-updates */ -import { existsSync } from 'fs'; +import { existsSync, readFileSync } from 'fs'; import * as path from 'path'; import * as vscode from 'vscode'; +import JSONC from 'jsonc-parser'; import { defaults, groupBy, isString, range } from 'lodash'; import tcpPortUsed from 'tcp-port-used'; import { getAhkVersion } from './util/getAhkVersion'; @@ -134,7 +135,10 @@ export class AhkConfigurationProvider implements vscode.DebugConfigurationProvid public config?: LaunchRequestArguments; public resolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken): vscode.ProviderResult { if (config.extends) { - const launch = vscode.workspace.getConfiguration().get>('launch'); + const launch = folder + ? JSONC.parse(readFileSync(path.resolve(folder.uri.fsPath, '.vscode', 'launch.json'), 'utf-8')) + : vscode.workspace.getConfiguration().get>('launch'); + if (launch && 'configurations' in launch && Array.isArray(launch.configurations)) { const sourceConfig = launch.configurations.find((conf) => equalsIgnoreCase(conf.name, config.extends)); if (!sourceConfig) {