diff --git a/resources/icons/dark/issue_webview.svg b/resources/icons/dark/issue_webview.svg new file mode 100644 index 0000000000..39f5281600 --- /dev/null +++ b/resources/icons/dark/issue_webview.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/resources/icons/issue_webview.svg b/resources/icons/issue_webview.svg new file mode 100644 index 0000000000..97b7e7f497 --- /dev/null +++ b/resources/icons/issue_webview.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/github/issueOverview.ts b/src/github/issueOverview.ts index 750b9130d7..41ed06c8b3 100644 --- a/src/github/issueOverview.ts +++ b/src/github/issueOverview.ts @@ -64,7 +64,7 @@ export class IssueOverviewPanel extends W if (panel) { panel._panel.reveal(activeColumn, true); } else { - const title = `Issue #${identity.number.toString()}`; + const title = `#${identity.number.toString()}`; panel = new IssueOverviewPanel( telemetry, extensionUri, @@ -108,6 +108,21 @@ export class IssueOverviewPanel extends W return this._panels.get(panelKey(owner, repo, number)); } + /** + * Build a short panel title: `# `. + * The item title is truncated to approximately `maxLength` characters on a + * word boundary and suffixed with "..." when it doesn't fit in full. + */ + protected buildPanelTitle(itemNumber: number, itemTitle: string, maxLength: number = 20): string { + let truncated = itemTitle; + if (itemTitle.length > maxLength) { + const lastSpace = itemTitle.lastIndexOf(' ', maxLength); + const cutOff = lastSpace > 0 ? lastSpace : maxLength; + truncated = itemTitle.substring(0, cutOff) + '...'; + } + return `#${itemNumber} ${truncated}`; + } + protected setPanelTitle(title: string): void { try { this._panel.title = title; @@ -125,10 +140,13 @@ export class IssueOverviewPanel extends W folderRepositoryManager: FolderRepositoryManager, private readonly type: string = IssueOverviewPanel.viewType, existingPanel?: vscode.WebviewPanel, - iconSubpath?: { + iconSubpath: { light: string, dark: string, - } + } = { + light: 'resources/icons/issue_webview.svg', + dark: 'resources/icons/dark/issue_webview.svg', + } ) { super(); this._folderRepositoryManager = folderRepositoryManager; @@ -144,12 +162,10 @@ export class IssueOverviewPanel extends W enableFindWidget: true })); - if (iconSubpath) { - this._panel.iconPath = { - dark: vscode.Uri.joinPath(_extensionUri, iconSubpath.dark), - light: vscode.Uri.joinPath(_extensionUri, iconSubpath.light) - }; - } + this._panel.iconPath = { + dark: vscode.Uri.joinPath(_extensionUri, iconSubpath.dark), + light: vscode.Uri.joinPath(_extensionUri, iconSubpath.light) + }; this._webview = this._panel.webview; super.initialize(); @@ -298,7 +314,7 @@ export class IssueOverviewPanel extends W } this._item = issue as TItem; - this.setPanelTitle(`Issue #${issueModel.number.toString()}`); + this.setPanelTitle(this.buildPanelTitle(issueModel.number, issueModel.title)); Logger.debug('pr.initialize', IssueOverviewPanel.ID); this._postMessage({ diff --git a/src/github/pullRequestOverview.ts b/src/github/pullRequestOverview.ts index 2b4f5f080f..dc424b7b59 100644 --- a/src/github/pullRequestOverview.ts +++ b/src/github/pullRequestOverview.ts @@ -91,7 +91,7 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel