Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The extends attribute in launch.json does not work in the multi-root workspace and throws an error #285

Open
Tracked by #214
zero-plusplus opened this issue Jan 27, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@zero-plusplus
Copy link
Owner

RELATED: #284

The following is how to fix it.

// extension.ts
public resolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration> {
    if (config.extends) {
      // Correction point -----------------------------------------------------------------------
      const launch = folder
        ? JSON.parse(readFileSync(path.resolve(folder.uri.fsPath, '.vscode', 'launch.json'), 'utf-8'))
        : vscode.workspace.getConfiguration().get<Record<string, any>>('launch');
      // ----------------------------------------------------------------------------------------
      if (launch && 'configurations' in launch && Array.isArray(launch.configurations)) {
        const sourceConfig = launch.configurations.find((conf) => equalsIgnoreCase(conf.name, config.extends));
        if (!sourceConfig) {
          throw Error(`No matching configuration found. Please modify the \`extends\` attribute. \nSpecified: ${String(config.extends)}`);
        }
        defaults(config, sourceConfig);
      }
    }
    // ...
}

When using workspace, no method was found to get the current debug configurations.
Therefore, reading launch.json directly solves this problem.

The above solution is probably not a legitimate method. In the first place, vscode developers may not expect to refer to other debug configuration such as extends.

@zero-plusplus zero-plusplus added the bug Something isn't working label Jan 27, 2023
This was referenced Jan 27, 2023
@zero-plusplus zero-plusplus changed the title The extends attribute does not work in the workspace and throws an error The extends attribute does not work in the multi-root workspace and throws an error Jan 30, 2023
@zero-plusplus zero-plusplus changed the title The extends attribute does not work in the multi-root workspace and throws an error The extends attribute in launch.json does not work in the multi-root workspace and throws an error Jan 30, 2023
zero-plusplus added a commit that referenced this issue Jan 30, 2023
The `extends` attribute does not work
in the multi-root workspace and throws an error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant