Let extensions prepopulate the issue reporter title and description (#91039)

* Let extensions prepopulate the issue reporter title and description

Fixes #91028

Adds two new optional arguments to the `vscode.openIssueReporter` command: `issueTitle` and `issueBody`. These are taken using an options object and are used to pre-populate the native issue reporter fields

Hooks up these fields for TypeScript's report issue prompt. We use this to post the most recent TS Server error stack

* Extract duplicate command id to constant

* Log version directly instead of prompting users for it
This commit is contained in:
Matt Bierner
2020-02-20 10:31:09 -08:00
committed by GitHub
parent 9061a91fed
commit 0b3aa0a6ea
8 changed files with 99 additions and 23 deletions

View File

@@ -97,6 +97,23 @@ export class IssueReporter extends Disposable {
this.previewButton = new Button(issueReporterElement);
}
const issueTitle = configuration.data.issueTitle;
if (issueTitle) {
const issueTitleElement = this.getElementById<HTMLInputElement>('issue-title');
if (issueTitleElement) {
issueTitleElement.value = issueTitle;
}
}
const issueBody = configuration.data.issueBody;
if (issueBody) {
const description = this.getElementById<HTMLTextAreaElement>('description');
if (description) {
description.value = issueBody;
this.issueReporterModel.update({ issueDescription: issueBody });
}
}
ipcRenderer.on('vscode:issuePerformanceInfoResponse', (_: unknown, info: Partial<IssueReporterData>) => {
this.logService.trace('issueReporter: Received performance data');
this.issueReporterModel.update(info);
@@ -1175,8 +1192,8 @@ export class IssueReporter extends Disposable {
}
}
private getElementById(elementId: string): HTMLElement | undefined {
const element = document.getElementById(elementId);
private getElementById<T extends HTMLElement = HTMLElement>(elementId: string): T | undefined {
const element = document.getElementById(elementId) as T | undefined;
if (element) {
return element;
} else {