diff --git a/src/client/common/application/commands/reportIssueCommand.ts b/src/client/common/application/commands/reportIssueCommand.ts index e5633f4a4389..ec97e0493b81 100644 --- a/src/client/common/application/commands/reportIssueCommand.ts +++ b/src/client/common/application/commands/reportIssueCommand.ts @@ -118,17 +118,21 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ return `|${extension.packageJSON.name}|${publisher}|${extension.packageJSON.version}|`; }); + const formattedDiagnosticData = userTemplate.format( + pythonVersion, + virtualEnvKind, + languageServer, + hasMultipleFoldersText, + userSettings, + installedExtensions.join('\n'), + ); + + // Replace the XXX placeholder in the diagnostic data section with the formatted diagnostic data + const issueBodyWithDiagnostics = template.replace('XXX', formattedDiagnosticData); + await this.commandManager.executeCommand('workbench.action.openIssueReporter', { extensionId: 'ms-python.python', - issueBody: template, - data: userTemplate.format( - pythonVersion, - virtualEnvKind, - languageServer, - hasMultipleFoldersText, - userSettings, - installedExtensions.join('\n'), - ), + issueBody: issueBodyWithDiagnostics, }); sendTelemetryEvent(EventName.USE_REPORT_ISSUE_COMMAND, undefined, {}); } diff --git a/src/test/common/application/commands/reportIssueCommand.unit.test.ts b/src/test/common/application/commands/reportIssueCommand.unit.test.ts index b1884fa83c21..fecb08bcf223 100644 --- a/src/test/common/application/commands/reportIssueCommand.unit.test.ts +++ b/src/test/common/application/commands/reportIssueCommand.unit.test.ts @@ -125,18 +125,20 @@ suite('Report Issue Command', () => { 'issueUserDataTemplateVenv1.md', ); const expectedData = fs.readFileSync(userDataTemplatePath, 'utf8'); + + // The expected result should be the template with XXX replaced by diagnostic data + const expectedCombinedIssueBody = expectedIssueBody.replace('XXX', expectedData); - const args: [string, { extensionId: string; issueBody: string; data: string }] = capture< + const args: [string, { extensionId: string; issueBody: string }] = capture< AllCommands, - { extensionId: string; issueBody: string; data: string } + { extensionId: string; issueBody: string } >(cmdManager.executeCommand).last(); verify(cmdManager.registerCommand(Commands.ReportIssue, anything(), anything())).once(); verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once(); expect(args[0]).to.be.equal('workbench.action.openIssueReporter'); - const { issueBody, data } = args[1]; - expect(issueBody).to.be.equal(expectedIssueBody); - expect(data).to.be.equal(expectedData); + const { issueBody } = args[1]; + expect(issueBody).to.be.equal(expectedCombinedIssueBody); }); test('Test if issue body is filled when only including settings which are explicitly set', async () => { @@ -166,17 +168,19 @@ suite('Report Issue Command', () => { 'issueUserDataTemplateVenv2.md', ); const expectedData = fs.readFileSync(userDataTemplatePath, 'utf8'); + + // The expected result should be the template with XXX replaced by diagnostic data + const expectedCombinedIssueBody = expectedIssueBody.replace('XXX', expectedData); - const args: [string, { extensionId: string; issueBody: string; data: string }] = capture< + const args: [string, { extensionId: string; issueBody: string }] = capture< AllCommands, - { extensionId: string; issueBody: string; data: string } + { extensionId: string; issueBody: string } >(cmdManager.executeCommand).last(); verify(cmdManager.executeCommand('workbench.action.openIssueReporter', anything())).once(); expect(args[0]).to.be.equal('workbench.action.openIssueReporter'); - const { issueBody, data } = args[1]; - expect(issueBody).to.be.equal(expectedIssueBody); - expect(data).to.be.equal(expectedData); + const { issueBody } = args[1]; + expect(issueBody).to.be.equal(expectedCombinedIssueBody); }); test('Should send telemetry event when run Report Issue Command', async () => { const sendTelemetryStub = sinon.stub(Telemetry, 'sendTelemetryEvent');