diff --git a/packages/ui/src/components/views/DiffView.tsx b/packages/ui/src/components/views/DiffView.tsx index aa6b883c..e269b8cc 100644 --- a/packages/ui/src/components/views/DiffView.tsx +++ b/packages/ui/src/components/views/DiffView.tsx @@ -1005,7 +1005,7 @@ const MultiFileDiffEntry = React.memo(({ filePath={file.path} staged={staged} busyAction={fileAction} - disabled={fileAction !== null} + disabled={fileAction !== null || hunkAction !== null} onAction={handleFileAction} /> ) : null} diff --git a/packages/ui/src/components/views/git/HunkActions.tsx b/packages/ui/src/components/views/git/HunkActions.tsx index 045062a9..612d7822 100644 --- a/packages/ui/src/components/views/git/HunkActions.tsx +++ b/packages/ui/src/components/views/git/HunkActions.tsx @@ -2,6 +2,7 @@ import React, { useMemo } from 'react'; import { DropdownMenu, DropdownMenuContent, + DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, @@ -27,7 +28,6 @@ interface HunkActionsProps { } interface HunkSummary { - patch: string; insertions: number; deletions: number; } @@ -41,9 +41,29 @@ const summarizeHunks = (patch: string): HunkSummary[] => if (line.startsWith('+')) insertions += 1; else if (line.startsWith('-')) deletions += 1; } - return { patch: hunkPatch, insertions, deletions }; + return { insertions, deletions }; }); +const HunkCounts = React.memo<{ insertions: number; deletions: number }>(function HunkCounts({ + insertions, + deletions, +}) { + if (insertions === 0 && deletions === 0) return null; + return ( + + {insertions > 0 ? ( + +{insertions} + ) : null} + {insertions > 0 && deletions > 0 ? ( + / + ) : null} + {deletions > 0 ? ( + -{deletions} + ) : null} + + ); +}); + export const HunkActions = React.memo(function HunkActions({ filePath, patch, @@ -84,51 +104,31 @@ export const HunkActions = React.memo(function HunkActions({ const displayIndex = index + 1; const busyPrimary = busyHunk?.index === index && busyHunk.action === primaryAction; const busyDiscard = busyHunk?.index === index && busyHunk.action === 'discard'; - const rowBusy = busyPrimary || busyDiscard; const primaryTitle = staged ? t('diffView.hunk.unstageTitle', { index: displayIndex }) : t('diffView.hunk.stageTitle', { index: displayIndex }); const discardTitle = t('diffView.hunk.discardTitle', { index: displayIndex }); return ( -
- - Hunk {displayIndex} - - {hunk.insertions > 0 ? ( - +{hunk.insertions} - ) : null} - {hunk.insertions > 0 && hunk.deletions > 0 ? ( - / - ) : null} - {hunk.deletions > 0 ? ( - -{hunk.deletions} - ) : null} - - - + {primaryTitle} + + {!staged ? ( - + {discardTitle} + ) : null} -
+ ); })}