diff --git a/src/renderer/src/components/editor/DiffSectionItem.tsx b/src/renderer/src/components/editor/DiffSectionItem.tsx index 225ab68c5c6..0a70adbf405 100644 --- a/src/renderer/src/components/editor/DiffSectionItem.tsx +++ b/src/renderer/src/components/editor/DiffSectionItem.tsx @@ -162,15 +162,37 @@ export function DiffSectionItem({ return (
toggleSection(index)} > { + role="button" + tabIndex={0} + className="cursor-copy hover:underline" + onMouseDown={(e) => { + e.preventDefault() e.stopPropagation() - navigator.clipboard.writeText(section.path) + }} + onClick={(e) => { + e.preventDefault() + e.stopPropagation() + // Why: stop both mouse-down and click on the path affordance so + // the parent section-toggle row cannot consume the interaction + // before the Electron clipboard write runs. + void window.api.ui.writeClipboardText(section.path).catch((err) => { + console.error('Failed to copy diff path:', err) + }) + }} + onKeyDown={(e) => { + if (e.key !== 'Enter' && e.key !== ' ') { + return + } + e.preventDefault() + e.stopPropagation() + void window.api.ui.writeClipboardText(section.path).catch((err) => { + console.error('Failed to copy diff path:', err) + }) }} title="Copy path" > @@ -179,7 +201,9 @@ export function DiffSectionItem({ {section.dirty && M} {lineStats && (lineStats.added > 0 || lineStats.removed > 0) && ( - {lineStats.added > 0 && +{lineStats.added}} + {lineStats.added > 0 && ( + +{lineStats.added} + )} {lineStats.added > 0 && lineStats.removed > 0 && } {lineStats.removed > 0 && -{lineStats.removed}}