Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps/web/src/components/DiffPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -776,12 +776,12 @@ export default function DiffPanel({
return next;
});
});
// Find can ask again before the unfolded file reaches the viewer, so this must never fold.
const unfoldDiffFile = useStableCallback((fileKey: string) => {
const setDiffFileCollapsed = useStableCallback((fileKey: string, collapsed: boolean) => {
updateCollapsedDiffFiles((current) => {
if (!current.has(fileKey)) return current;
if (current.has(fileKey) === collapsed) return current;
const next = new Set(current);
next.delete(fileKey);
if (collapsed) next.add(fileKey);
else next.delete(fileKey);
return next;
});
});
Expand Down Expand Up @@ -1458,7 +1458,7 @@ export default function DiffPanel({
},
}
: {})}
onRevealSearchMatch={unfoldDiffFile}
onFileCollapsedChange={setDiffFileCollapsed}
renderHeaderPrefix={(fileDiff, fileKey, collapsed) => {
return (
<DiffFileCollapseToggle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function view(
options={{}}
renderHeaderFilenameSuffix={() => null}
renderHeaderPrefix={() => null}
onRevealSearchMatch={() => {}}
onFileCollapsedChange={() => {}}
/>
</StrictMode>
);
Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/components/diffs/AnnotatableCodeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ interface AnnotatableCodeViewProps {
fileKey: string,
collapsed: boolean,
) => ReactNode;
onRevealSearchMatch: (fileKey: string) => void;
onFileCollapsedChange: (fileKey: string, collapsed: boolean) => void;
}

interface DiffSelectionContext {
Expand All @@ -124,7 +124,7 @@ export function AnnotatableCodeView({
renderHeaderMetadata,
renderHeaderFilenameSuffix,
renderHeaderPrefix,
onRevealSearchMatch,
onFileCollapsedChange,
}: AnnotatableCodeViewProps) {
const addReviewComment = useComposerDraftStore((store) => store.addReviewComment);
const removeReviewComment = useComposerDraftStore((store) => store.removeReviewComment);
Expand Down Expand Up @@ -280,7 +280,8 @@ export function AnnotatableCodeView({
enableGutterUtility: draft === null,
enableLineSelection: draft === null,
onGutterUtilityClick: beginComment,
onRevealSearchMatch: (item) => onRevealSearchMatch(item.id),
onItemCollapsedChange: (_item, nextItem) =>
onFileCollapsedChange(nextItem.id, nextItem.collapsed === true),
}}
renderHeaderFilenameSuffix={(item) =>
item.type === "diff" ? renderHeaderFilenameSuffix(item.fileDiff) : null
Expand Down
87 changes: 0 additions & 87 deletions apps/web/src/components/diffs/codeViewSearch.browser.test.ts

This file was deleted.

10 changes: 7 additions & 3 deletions apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,13 @@ function PullRequestCodeTab({
onGutterUtilityClick: beginComment,
onLineSelectionEnd: beginComment,
onPostRender: codeViewReveal.flush,
// Find may repeat requests before render; only unfold, never toggle.
onRevealSearchMatch: (item: CodeViewItem<ReviewAnnotationGroup>) =>
setFoldChoices((current) => withFileDiffFold(current, item.id, false)),
onItemCollapsedChange: (
_item: CodeViewItem<ReviewAnnotationGroup>,
nextItem: CodeViewItem<ReviewAnnotationGroup>,
) =>
setFoldChoices((current) =>
withFileDiffFold(current, nextItem.id, nextItem.collapsed === true),
),
};

const runThreadCommand = async (
Expand Down
Loading
Loading