Skip to content

Commit f5d427f

Browse files
committed
fix #4101 sort of. Just make it slightly better in an edge case...
- not worth more than a minute
1 parent 7e23033 commit f5d427f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/packages/frontend/project/explorer/file-listing/file-listing.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,18 @@ export const FileListing: React.FC<Props> = ({
167167
});
168168
const virtuosoRef = useRef<VirtuosoHandle>(null);
169169

170+
const lastSelectedFileIndexRef = useRef<undefined | number>(selected_file_index);
171+
170172
useEffect(() => {
171-
if (selected_file_index == null) return;
172-
virtuosoRef.current?.scrollIntoView({ index: selected_file_index });
173+
if (selected_file_index == null) {
174+
return;
175+
}
176+
if (lastSelectedFileIndexRef.current == selected_file_index - 1) {
177+
virtuosoRef.current?.scrollIntoView({ index: selected_file_index + 1 });
178+
} else {
179+
virtuosoRef.current?.scrollIntoView({ index: selected_file_index });
180+
}
181+
lastSelectedFileIndexRef.current = selected_file_index;
173182
}, [selected_file_index]);
174183

175184
function render_rows(): Rendered {

0 commit comments

Comments
 (0)