5
5
6
6
import { URI } from 'vs/base/common/uri' ;
7
7
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' ;
9
9
import { ExtensionType } from 'vs/platform/extensions/common/extensions' ;
10
10
import { IOpenerService } from 'vs/platform/opener/common/opener' ;
11
11
import { IProductService } from 'vs/platform/product/common/productService' ;
@@ -28,27 +28,29 @@ export class WebIssueService implements IWorkbenchIssueService {
28
28
29
29
async openReporter ( options : Partial < IssueReporterData > ) : Promise < void > {
30
30
let repositoryUrl = this . productService . reportIssueUrl ;
31
+ let selectedExtension : ILocalExtension | undefined ;
31
32
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 ) ;
33
36
if ( extensionGitHubUrl ) {
34
- repositoryUrl = extensionGitHubUrl + ' /issues/new' ;
37
+ repositoryUrl = ` ${ extensionGitHubUrl } /issues/new` ;
35
38
}
36
39
}
37
40
38
41
if ( repositoryUrl ) {
42
+ repositoryUrl = `${ repositoryUrl } ?body=${ encodeURIComponent ( await this . getIssueDescription ( selectedExtension ) ) } ` ;
39
43
return this . openerService . open ( URI . parse ( repositoryUrl ) ) . then ( _ => { } ) ;
40
44
} else {
41
45
throw new Error ( `Unable to find issue reporting url for ${ options . extensionId } ` ) ;
42
46
}
43
47
}
44
48
45
- private async getExtensionGitHubUrl ( extensionId : string ) : Promise < string > {
49
+ private async getExtensionGitHubUrl ( extension : ILocalExtension ) : Promise < string > {
46
50
let repositoryUrl = '' ;
47
51
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 ;
52
54
53
55
// If given, try to match the extension's bug url
54
56
if ( bugsUrl && bugsUrl . match ( / ^ h t t p s ? : \/ \/ g i t h u b \. c o m \/ ( .* ) / ) ) {
@@ -59,4 +61,16 @@ export class WebIssueService implements IWorkbenchIssueService {
59
61
60
62
return repositoryUrl ;
61
63
}
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
+ }
62
76
}
0 commit comments