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

@@ -529,7 +529,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType
id: MessageAction;
}
const previousVersion = this.apiVersion;
const previousState = this.serverState;
this.serverState = ServerState.None;
if (restart) {
const diff = Date.now() - this.lastStart;
this.numberRestarts++;
@@ -565,8 +568,11 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}
if (prompt) {
prompt.then(item => {
if (item && item.id === MessageAction.reportIssue) {
return vscode.commands.executeCommand('workbench.action.openIssueReporter');
if (item?.id === MessageAction.reportIssue) {
const args = previousState.type === ServerState.Type.Errored && previousState.error instanceof TypeScriptServerError
? getReportIssueArgsForError(previousState.error, previousVersion)
: undefined;
return vscode.commands.executeCommand('workbench.action.openIssueReporter', args);
}
return undefined;
});
@@ -719,9 +725,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}
private fatalError(command: string, error: unknown): void {
if (!(error instanceof TypeScriptServerError)) {
console.log('fdasfasdf');
}
/* __GDPR__
"fatalError" : {
"${include}": [
@@ -740,6 +743,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType
if (this.serverState.type === ServerState.Type.Running) {
this.info('Killing TS Server');
this.serverState.server.kill();
if (error instanceof TypeScriptServerError) {
this.serverState = new ServerState.Errored(error);
}
}
}
@@ -869,6 +875,32 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}
}
function getReportIssueArgsForError(error: TypeScriptServerError, apiVersion: API): { issueTitle: string, issueBody: string } | undefined {
if (!error.serverStack || !error.serverMessage) {
return undefined;
}
// Note these strings are intentionally not localized
// as we want users to file issues in english
return {
issueTitle: `TS Server fatal error: ${error.serverMessage}`,
issueBody: `**TypeScript Version:** ${apiVersion.fullVersionString}
**Steps to reproduce crash**
1.
2.
3.
** TS Server Error Stack **
\`\`\`
${error.serverStack}
\`\`\``,
};
}
function getDignosticsKind(event: Proto.Event) {
switch (event.event) {
case 'syntaxDiag': return DiagnosticKind.Syntax;