feat(agent-manager): jump to changed line when clicking line number in diff (#8866)
* feat(agent-manager): jump to changed line when clicking line number in diff When clicking a line number in the diff review panel (DiffPanel or FullScreenDiffView), open the file in the editor at that exact line instead of always landing on line 1. Closes #6076 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * style: fix prettier formatting in AgentManagerApp Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3016,10 +3016,11 @@ const AgentManagerContent: Component = () => {
|
||||
onClose={() => setSidePanel(null)}
|
||||
onExpand={selection() !== null ? openReviewTab : undefined}
|
||||
onRequestDiff={requestDiffFile}
|
||||
onOpenFile={(file) => {
|
||||
onOpenFile={(file, line) => {
|
||||
const id = currentDiffSessionId()
|
||||
if (id) vscode.postMessage({ type: "agentManager.openFile", sessionId: id, filePath: file })
|
||||
else if (selection() === LOCAL) vscode.postMessage({ type: "openFile", filePath: file })
|
||||
if (id)
|
||||
vscode.postMessage({ type: "agentManager.openFile", sessionId: id, filePath: file, line })
|
||||
else if (selection() === LOCAL) vscode.postMessage({ type: "openFile", filePath: file, line })
|
||||
}}
|
||||
onRevertFile={revertCtl.revert}
|
||||
revertingFiles={revertCtl.reverting()}
|
||||
@@ -3044,10 +3045,10 @@ const AgentManagerContent: Component = () => {
|
||||
diffStyle={reviewDiffStyle()}
|
||||
onDiffStyleChange={setSharedDiffStyle}
|
||||
onRequestDiff={requestDiffFile}
|
||||
onOpenFile={(file) => {
|
||||
onOpenFile={(file, line) => {
|
||||
const id = currentDiffSessionId()
|
||||
if (id) vscode.postMessage({ type: "agentManager.openFile", sessionId: id, filePath: file })
|
||||
else if (selection() === LOCAL) vscode.postMessage({ type: "openFile", filePath: file })
|
||||
if (id) vscode.postMessage({ type: "agentManager.openFile", sessionId: id, filePath: file, line })
|
||||
else if (selection() === LOCAL) vscode.postMessage({ type: "openFile", filePath: file, line })
|
||||
}}
|
||||
onRevertFile={revertCtl.revert}
|
||||
revertingFiles={revertCtl.reverting()}
|
||||
|
||||
@@ -40,7 +40,7 @@ interface DiffPanelProps {
|
||||
onClose: () => void
|
||||
onExpand?: () => void
|
||||
onRequestDiff?: (file: string) => void
|
||||
onOpenFile?: (relativePath: string) => void
|
||||
onOpenFile?: (relativePath: string, line?: number) => void
|
||||
onRevertFile?: (file: string) => void
|
||||
revertingFiles?: Set<string>
|
||||
}
|
||||
@@ -520,6 +520,10 @@ export const DiffPanel: Component<DiffPanelProps> = (props) => {
|
||||
renderAnnotation={buildAnnotation}
|
||||
enableGutterUtility={true}
|
||||
onGutterUtilityClick={(result) => handleGutterClick(diff.file, result)}
|
||||
onLineNumberClick={(event) => {
|
||||
if (event.annotationSide === "deletions") return
|
||||
props.onOpenFile?.(diff.file, event.lineNumber)
|
||||
}}
|
||||
/>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
@@ -40,7 +40,7 @@ interface FullScreenDiffViewProps {
|
||||
diffStyle: DiffStyle
|
||||
onDiffStyleChange: (style: DiffStyle) => void
|
||||
onRequestDiff?: (file: string) => void
|
||||
onOpenFile?: (relativePath: string) => void
|
||||
onOpenFile?: (relativePath: string, line?: number) => void
|
||||
onRevertFile?: (file: string) => void
|
||||
revertingFiles?: Set<string>
|
||||
onClose: () => void
|
||||
@@ -596,6 +596,10 @@ export const FullScreenDiffView: Component<FullScreenDiffViewProps> = (props) =>
|
||||
renderAnnotation={buildAnnotation}
|
||||
enableGutterUtility={true}
|
||||
onGutterUtilityClick={(result) => handleGutterClick(diff.file, result)}
|
||||
onLineNumberClick={(event) => {
|
||||
if (event.annotationSide === "deletions") return
|
||||
props.onOpenFile?.(diff.file, event.lineNumber)
|
||||
}}
|
||||
/>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
@@ -143,7 +143,7 @@ const unsafeCSS = `
|
||||
}
|
||||
|
||||
&[data-interactive-line-numbers] [data-column-number] {
|
||||
cursor: default !important;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
&[data-interactive-lines] [data-line] {
|
||||
|
||||
Reference in New Issue
Block a user