Skip to content

Commit ea00721

Browse files
committed
Avoid scrolling to filtered-out file
1 parent 92eb81d commit ea00721

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

web/src/lib/diff-viewer.svelte.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,12 @@ export class MultiFileDiffViewerState {
533533

534534
scrollToFile(fileIdx: number, options: { autoExpand?: boolean; smooth?: boolean; focus?: boolean } = {}) {
535535
if (!this.vlist) return;
536+
const vlistFileIdx = this.filteredFileDetails.vlistIndices[fileIdx];
537+
if (vlistFileIdx === -1) {
538+
// File is filtered out, cannot scroll to it.
539+
// This should only happen when a file is selected via URL but excluded by default filters.
540+
return;
541+
}
536542

537543
const autoExpand = options.autoExpand ?? true;
538544
const smooth = options.smooth ?? false;
@@ -543,7 +549,6 @@ export class MultiFileDiffViewerState {
543549
// Auto-expand on jump when not checked
544550
fileState.collapsed = false;
545551
}
546-
const vlistFileIdx = this.filteredFileDetails.vlistIndices[fileIdx];
547552
this.vlist.scrollToIndex(vlistFileIdx, { align: "start", smooth });
548553
if (focus) {
549554
requestAnimationFrame(() => {

0 commit comments

Comments
 (0)