提交 e0e11632 编写于 作者: R Rachel Macfarlane

Lack of feedback when searching for similar issues in extensions when...

Lack of feedback when searching for similar issues in extensions when reporting an issue on an extension, fixes #50656
上级 4f324d17
......@@ -40,7 +40,7 @@ import { createSpdLogService } from 'vs/platform/log/node/spdlogService';
import { LogLevelSetterChannelClient, FollowerLogService } from 'vs/platform/log/common/logIpc';
import { ILogService, getLogLevel } from 'vs/platform/log/common/log';
import { OcticonLabel } from 'vs/base/browser/ui/octiconLabel/octiconLabel';
import { normalizeGitHubIssuesUrl } from 'vs/code/electron-browser/issue/issueReporterUtil';
import { normalizeGitHubUrl } from 'vs/code/electron-browser/issue/issueReporterUtil';
import { Button } from 'vs/base/browser/ui/button/button';
const MAX_URL_LENGTH = platform.isWindows ? 2081 : 5400;
......@@ -466,13 +466,20 @@ export class IssueReporter extends Disposable {
}
private searchExtensionIssues(title: string): void {
const url = this.getExtensionRepositoryUrl();
const url = this.getExtensionGitHubUrl();
if (title) {
const matches = /^https?:\/\/github\.com\/(.*)(?:.git)/.exec(url);
const matches = /^https?:\/\/github\.com\/(.*)/.exec(url);
if (matches && matches.length) {
const repo = matches[1];
return this.searchGitHub(repo, title);
}
// If the extension has no repository, display empty search results
if (this.issueReporterModel.getData().selectedExtension) {
this.clearSearchResults();
return this.displaySearchResults([]);
}
}
this.clearSearchResults();
......@@ -771,16 +778,26 @@ export class IssueReporter extends Disposable {
return true;
}
private getExtensionGitHubUrl(): string {
let repositoryUrl = '';
const bugsUrl = this.getExtensionBugsUrl();
const extensionUrl = this.getExtensionRepositoryUrl();
// If given, try to match the extension's bug url
if (bugsUrl && bugsUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
repositoryUrl = normalizeGitHubUrl(bugsUrl);
} else if (extensionUrl && extensionUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
repositoryUrl = normalizeGitHubUrl(extensionUrl);
}
return repositoryUrl;
}
private getIssueUrlWithTitle(issueTitle: string): string {
let repositoryUrl = product.reportIssueUrl;
if (this.issueReporterModel.fileOnExtension()) {
const bugsUrl = this.getExtensionBugsUrl();
const extensionUrl = this.getExtensionRepositoryUrl();
// If given, try to match the extension's bug url
if (bugsUrl && bugsUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
repositoryUrl = normalizeGitHubIssuesUrl(bugsUrl);
} else if (extensionUrl && extensionUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
repositoryUrl = normalizeGitHubIssuesUrl(extensionUrl);
const extensionGitHubUrl = this.getExtensionGitHubUrl();
if (extensionGitHubUrl) {
repositoryUrl = extensionGitHubUrl + '/issues/new';
}
}
......
......@@ -7,7 +7,7 @@
import { endsWith, rtrim } from 'vs/base/common/strings';
export function normalizeGitHubIssuesUrl(url: string): string {
export function normalizeGitHubUrl(url: string): string {
// If the url has a .git suffix, remove it
if (endsWith(url, '.git')) {
url = url.substr(0, url.length - 4);
......@@ -16,15 +16,13 @@ export function normalizeGitHubIssuesUrl(url: string): string {
// Remove trailing slash
url = rtrim(url, '/');
// If the url already ends with issues/new, it's beautiful, return it
if (endsWith(url, 'issues/new')) {
return url;
if (endsWith(url, '/new')) {
url = rtrim(url, '/new');
}
// Add new segment if it does not exist
if (endsWith(url, 'issues')) {
return url + '/new';
if (endsWith(url, '/issues')) {
url = rtrim(url, '/issues');
}
return url + '/issues/new';
return url;
}
\ No newline at end of file
......@@ -7,7 +7,7 @@
import * as assert from 'assert';
import { IssueReporterModel } from 'vs/code/electron-browser/issue/issueReporterModel';
import { normalizeGitHubIssuesUrl } from 'vs/code/electron-browser/issue/issueReporterUtil';
import { normalizeGitHubUrl } from 'vs/code/electron-browser/issue/issueReporterUtil';
import { IssueType } from 'vs/platform/issue/common/issue';
suite('IssueReporter', () => {
......@@ -79,7 +79,7 @@ OS version: undefined
'https://github.com/repo/issues/new',
'https://github.com/repo/issues/new/'
].forEach(url => {
assert.equal('https://github.com/repo/issues/new', normalizeGitHubIssuesUrl(url));
assert.equal('https://github.com/repo', normalizeGitHubUrl(url));
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册