From 06b1e712bba4332cbd56a7d4cd8089b6e17aba13 Mon Sep 17 00:00:00 2001 From: netcon Date: Tue, 24 May 2022 21:30:16 +0800 Subject: [PATCH] fix: commit list item description not shown --- extensions/github1s/src/views/code-review-list.ts | 2 +- extensions/github1s/src/views/commit-list.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/extensions/github1s/src/views/code-review-list.ts b/extensions/github1s/src/views/code-review-list.ts index 5a1440159..945a105e6 100644 --- a/extensions/github1s/src/views/code-review-list.ts +++ b/extensions/github1s/src/views/code-review-list.ts @@ -43,7 +43,7 @@ const statusIconMap = { export const getCodeReviewTreeItemLabel = (codeReview: adapterTypes.CodeReview) => { const statusIcon = statusIconMap[getCodeReviewStatus(codeReview)]; - return `${statusIcon} #${codeReview.id} ${codeReview.title}`; + return `${statusIcon} #${codeReview.id} ${codeReview.title.split(/[\r\n]/)[0]}`; }; export const getCodeReviewTreeItemDescription = (codeReview: adapterTypes.CodeReview) => { diff --git a/extensions/github1s/src/views/commit-list.ts b/extensions/github1s/src/views/commit-list.ts index 80b098e38..b2cd68726 100644 --- a/extensions/github1s/src/views/commit-list.ts +++ b/extensions/github1s/src/views/commit-list.ts @@ -15,7 +15,9 @@ import { getChangedFileDiffCommand, getCommitChangedFiles } from '@/changes/file import { GitHub1sSourceControlDecorationProvider } from '@/providers/decorations/source-control'; export const getCommitTreeItemDescription = (commit: adapterTypes.Commit): string => { - return [commit.sha.slice(0, 7), commit.author, relativeTimeTo(commit.createTime)].join(', '); + const shortCommitSha = commit.sha.slice(0, 7); + const relativeTimeStr = commit.createTime ? relativeTimeTo(commit.createTime) : null; + return [shortCommitSha, commit.author, relativeTimeStr].filter(Boolean).join(', '); }; export interface CommitTreeItem extends vscode.TreeItem { @@ -91,9 +93,9 @@ export class CommitTreeDataProvider implements vscode.TreeDataProvider { - const label = `${commit.message}`; + const label = commit.message.split(/[\r\n]/)[0]; const description = getCommitTreeItemDescription(commit); - const tooltip = `${label} (${description})`; + const tooltip = `${commit.message}\n(${description})`; const iconPath = vscode.Uri.parse(commit.avatarUrl || ''); const contextValue = 'github1s:viewItems:commitListItem';