Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions resources/icons/dark/issue_webview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions resources/icons/issue_webview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 26 additions & 10 deletions src/github/issueOverview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> 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,
Expand Down Expand Up @@ -108,6 +108,21 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
return this._panels.get(panelKey(owner, repo, number));
}

/**
* Build a short panel title: `#<number> <truncated 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;
Expand All @@ -125,10 +140,13 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> 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;
Expand All @@ -144,12 +162,10 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> 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();
Expand Down Expand Up @@ -298,7 +314,7 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> 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({
Expand Down
4 changes: 2 additions & 2 deletions src/github/pullRequestOverview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
if (panel) {
panel._panel.reveal(activeColumn, preserveFocus);
} else {
const title = `Pull Request #${identity.number.toString()}`;
const title = `#${identity.number.toString()}`;
panel = new PullRequestOverviewPanel(
telemetry,
extensionUri,
Expand Down Expand Up @@ -375,7 +375,7 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
this._repositoryDefaultBranch = defaultBranch!;
this._teamsCount = orgTeamsCount;
this._assignableUsers = assignableUsers;
this.setPanelTitle(`Pull Request #${pullRequestModel.number.toString()}`);
this.setPanelTitle(this.buildPanelTitle(pullRequestModel.number, pullRequestModel.title));

const isCurrentlyCheckedOut = pullRequestModel.equals(this._folderRepositoryManager.activePullRequest);
const mergeMethodsAvailability = repositoryAccess!.mergeMethodsAvailability;
Expand Down
Loading