@@ -511,12 +511,24 @@ export default function FileBrowserPanel({ |
511 | 511 | else handledRevealRef.current = null; |
512 | 512 | return; |
513 | 513 | } |
514 | | - // Entry refreshes rebuild treePaths while the same preview stays open. |
515 | | - // Replaying a handled reveal would close an active tree search and steal focus. |
516 | | - if (sameReveal && !handledReveal.selectionMissing) return; |
517 | 514 | const selectedTreePath = selectedKind === "directory" ? `${selectedPath}/` : selectedPath; |
518 | 515 | const selectedItem = model.getItem(selectedTreePath); |
519 | 516 | if (!selectedItem) return; |
| 517 | + const acknowledgeReveal = () => { |
| 518 | + // Search-only rows can disappear before their directory listings arrive. |
| 519 | + if ( |
| 520 | + !selectedPathRevealHandled && |
| 521 | + directoryEntries.some((entry) => entry.path === selectedPath) |
| 522 | + ) { |
| 523 | + onSelectedPathRevealHandled(); |
| 524 | + } |
| 525 | + }; |
| 526 | + // Entry refreshes rebuild treePaths while the same preview stays open. |
| 527 | + // Replaying a handled reveal would close an active tree search and steal focus. |
| 528 | + if (sameReveal && !handledReveal.selectionMissing) { |
| 529 | + acknowledgeReveal(); |
| 530 | + return; |
| 531 | + } |
520 | 532 | // A retained preview needs selection in the new model without replaying its reveal. |
521 | 533 | if (skipInitialReveal || (sameReveal && model.isSearchOpen())) { |
522 | 534 | handledRevealRef.current = revealRequest; |
@@ -525,6 +537,7 @@ export default function FileBrowserPanel({ |
525 | 537 | model.getItem(path)?.deselect(); |
526 | 538 | } |
527 | 539 | selectedItem.select(); |
| 540 | + acknowledgeReveal(); |
528 | 541 | queueMicrotask(() => { |
529 | 542 | syncingSelectionRef.current = false; |
530 | 543 | }); |
@@ -541,12 +554,11 @@ export default function FileBrowserPanel({ |
541 | 554 | if (selectedInTree && treeSelectionPathRef.current === selectedPath) { |
542 | 555 | treeSelectionPathRef.current = null; |
543 | 556 | handledRevealRef.current = revealRequest; |
544 | | - onSelectedPathRevealHandled(); |
| 557 | + acknowledgeReveal(); |
545 | 558 | return; |
546 | 559 | } |
547 | 560 | treeSelectionPathRef.current = null; |
548 | 561 | handledRevealRef.current = revealRequest; |
549 | | - onSelectedPathRevealHandled(); |
550 | 562 |
|
551 | 563 | syncingSelectionRef.current = true; |
552 | 564 | setQuery(""); |
@@ -571,14 +583,17 @@ export default function FileBrowserPanel({ |
571 | 583 | focus: true, |
572 | 584 | offset: "center", |
573 | 585 | }); |
| 586 | + acknowledgeReveal(); |
574 | 587 | queueMicrotask(() => { |
575 | 588 | syncingSelectionRef.current = false; |
576 | 589 | }); |
577 | 590 | }, [ |
| 591 | + directoryEntries, |
578 | 592 | entryKinds, |
579 | 593 | model, |
580 | 594 | selectedPath, |
581 | 595 | selectedPathRevealId, |
| 596 | + selectedPathRevealHandled, |
582 | 597 | shouldSkipInitialReveal, |
583 | 598 | onSelectedPathRevealHandled, |
584 | 599 | ]); |
|