From 3499119e69b59293dc2193c3b59a5f497807d191 Mon Sep 17 00:00:00 2001 From: Sergei Shmakov Date: Wed, 20 Nov 2024 12:58:03 +0100 Subject: [PATCH] Adds hover tooltip on an issue item in Start Work by extending `details` (#3743, #3778) --- src/plus/startWork/startWork.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plus/startWork/startWork.ts b/src/plus/startWork/startWork.ts index aaa3d962e41db..1b799b74975c2 100644 --- a/src/plus/startWork/startWork.ts +++ b/src/plus/startWork/startWork.ts @@ -415,6 +415,7 @@ export class StartWorkCommand extends QuickCommand { ): StepResultGenerator { const buildIssueItem = (i: StartWorkItem) => { const buttons = i.item.issue.url ? [OpenOnGitHubQuickInputButton] : []; + const hoverContent = i.item.issue.body ? `${repeatSpaces(200)}\n\n${i.item.issue.body}` : ''; return { label: i.item.issue.title.length > 60 ? `${i.item.issue.title.substring(0, 60)}...` : i.item.issue.title, @@ -422,7 +423,8 @@ export class StartWorkCommand extends QuickCommand { description: `\u00a0 ${ i.item.issue.repository ? `${i.item.issue.repository.owner}/${i.item.issue.repository.repo}#` : '' }${i.item.issue.id} \u00a0`, - detail: ` ${fromNow(i.item.issue.updatedDate)} by @${i.item.issue.author.name}`, + // The spacing here at the beginning is used to align the description with the title. Otherwise it starts under the avatar icon: + detail: ` ${fromNow(i.item.issue.updatedDate)} by @${i.item.issue.author.name}${hoverContent}`, iconPath: i.item.issue.author?.avatarUrl != null ? Uri.parse(i.item.issue.author.avatarUrl) : undefined, item: i, picked: i.item.issue.id === state.item?.item?.issue.id, @@ -567,6 +569,10 @@ function isStartWorkTypeItem(item: unknown): item is StartWorkTypeItem { return item != null && typeof item === 'object' && 'type' in item; } +function repeatSpaces(count: number) { + return ' '.repeat(count); +} + export function getStartWorkItemIdHash(item: StartWorkItem) { return md5(item.item.issue.id); }