diff --git a/CHANGELOG.md b/CHANGELOG.md index 53810a34..af7ffa5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +## [4.3.11] + ## [4.3.10] - 2022-12-26 ### Fixed diff --git a/src/WorkspaceManager.ts b/src/WorkspaceManager.ts index 7e983869..967c2208 100644 --- a/src/WorkspaceManager.ts +++ b/src/WorkspaceManager.ts @@ -380,16 +380,26 @@ export class WorkspaceManager implements vscode.Disposable { } } - debug(test: AbstractTest, cancellation: vscode.CancellationToken, run: vscode.TestRun): Promise { + debug( + test: AbstractTest, + cancellation: vscode.CancellationToken, + run: vscode.TestRun, + setDebugArgs: (args: string[]) => void, + ): Promise { run.enqueued(test.item); - return this._debugInner(test, cancellation, run).catch(e => { + return this._debugInner(test, cancellation, run, setDebugArgs).catch(e => { this.log.errorS('error during debug', e); throw e; }); } - async _debugInner(test: AbstractTest, cancellation: vscode.CancellationToken, run: vscode.TestRun): Promise { + async _debugInner( + test: AbstractTest, + cancellation: vscode.CancellationToken, + run: vscode.TestRun, + setDebugArgs: (args: string[]) => void, + ): Promise { try { this._shared.log.info('Using debug'); @@ -401,6 +411,7 @@ export class WorkspaceManager implements vscode.Disposable { const configuration = this._getConfiguration(this._shared.log); const argsArray = executable.getDebugParams([test], configuration.getDebugBreakOnFailure()); + setDebugArgs(argsArray); const argsArrayFunc = async (): Promise => argsArray; @@ -451,7 +462,7 @@ export class WorkspaceManager implements vscode.Disposable { { resolve: '${argsArrayFlat}', rule: argsArrayFunc, isFlat: true }, { resolve: '${argsStr}', - rule: (): string => '"' + argsArray.map(a => a.replace('"', '\\"')).join('" "') + '"', + rule: (): string => '"' + argsArray.map(a => a.replaceAll('"', '\\"')).join('" "') + '"', }, { resolve: '${cwd}', rule: executable.shared.options.cwd!.toString() }, { diff --git a/src/main.ts b/src/main.ts index 0380db2a..c167fd4b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -165,6 +165,9 @@ export async function activate(context: vscode.ExtensionContext): Promise SharedTestTags.runnable, ); + // https://github.com/matepek/vscode-catch2-test-adapter/issues/375 + let currentDebugArgs: string[] = []; + const debugProfile = controller.createRunProfile( 'Debug Test', vscode.TestRunProfileKind.Debug, @@ -205,9 +208,12 @@ export async function activate(context: vscode.ExtensionContext): Promise } const test = testsToRun.direct[0]; runQueue.push( - manager.debug(test, cancellation, testRun).catch(e => { - vscode.window.showErrorMessage('Unexpected error from debug: ' + e); - }), + manager + .debug(test, cancellation, testRun, (args: string[]) => (currentDebugArgs = args)) + .catch(e => { + vscode.window.showErrorMessage('Unexpected error from debug: ' + e); + }) + .finally(() => (currentDebugArgs = [])), ); } @@ -245,6 +251,12 @@ export async function activate(context: vscode.ExtensionContext): Promise vscode.commands.registerCommand('testMate.cmd.reload-workspaces', commandReloadWorkspaces), ); + context.subscriptions.push( + vscode.commands.registerCommand('testMate.cmd.get-debug-args', () => + currentDebugArgs.map(a => a.replaceAll('"', '\\"')).join('" "'), + ), + ); + addOpenedWorkspaces(); log.info('Activation finished');