Skip to content

Commit cad4c19

Browse files
Have web issue reporter be a little more useful
1 parent c986aef commit cad4c19

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/vs/workbench/contrib/issue/browser/issueService.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { URI } from 'vs/base/common/uri';
77
import { normalizeGitHubUrl } from 'vs/platform/issue/common/issueReporterUtil';
8-
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
8+
import { IExtensionManagementService, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
99
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
1010
import { IOpenerService } from 'vs/platform/opener/common/opener';
1111
import { IProductService } from 'vs/platform/product/common/productService';
@@ -28,27 +28,29 @@ export class WebIssueService implements IWorkbenchIssueService {
2828

2929
async openReporter(options: Partial<IssueReporterData>): Promise<void> {
3030
let repositoryUrl = this.productService.reportIssueUrl;
31+
let selectedExtension: ILocalExtension | undefined;
3132
if (options.extensionId) {
32-
const extensionGitHubUrl = await this.getExtensionGitHubUrl(options.extensionId);
33+
const extensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
34+
selectedExtension = extensions.filter(ext => ext.identifier.id === options.extensionId)[0];
35+
const extensionGitHubUrl = await this.getExtensionGitHubUrl(selectedExtension);
3336
if (extensionGitHubUrl) {
34-
repositoryUrl = extensionGitHubUrl + '/issues/new';
37+
repositoryUrl = `${extensionGitHubUrl}/issues/new`;
3538
}
3639
}
3740

3841
if (repositoryUrl) {
42+
repositoryUrl = `${repositoryUrl}?body=${encodeURIComponent(await this.getIssueDescription(selectedExtension))}`;
3943
return this.openerService.open(URI.parse(repositoryUrl)).then(_ => { });
4044
} else {
4145
throw new Error(`Unable to find issue reporting url for ${options.extensionId}`);
4246
}
4347
}
4448

45-
private async getExtensionGitHubUrl(extensionId: string): Promise<string> {
49+
private async getExtensionGitHubUrl(extension: ILocalExtension): Promise<string> {
4650
let repositoryUrl = '';
4751

48-
const extensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
49-
const selectedExtension = extensions.filter(ext => ext.identifier.id === extensionId)[0];
50-
const bugsUrl = selectedExtension?.manifest.bugs?.url;
51-
const extensionUrl = selectedExtension?.manifest.repository?.url;
52+
const bugsUrl = extension?.manifest.bugs?.url;
53+
const extensionUrl = extension?.manifest.repository?.url;
5254

5355
// If given, try to match the extension's bug url
5456
if (bugsUrl && bugsUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
@@ -59,4 +61,16 @@ export class WebIssueService implements IWorkbenchIssueService {
5961

6062
return repositoryUrl;
6163
}
64+
65+
private async getIssueDescription(extension: ILocalExtension | undefined): Promise<string> {
66+
return `
67+
Issue Type (Please pick one): <b>Bug | Feature request</b>
68+
69+
ADD ISSUE DESCRIPTION HERE
70+
71+
${extension?.manifest.version ? `\nExtension version: ${extension.manifest.version}` : ''}
72+
VS Code version: ${this.productService.version}
73+
OS version: Web
74+
<!-- generated by web issue reporter -->`;
75+
}
6276
}

0 commit comments

Comments
 (0)