(file)
| 1600 | } |
| 1601 | |
| 1602 | function restoreFileScrollPosition(file) { |
| 1603 | cancelPendingScrollRestore(); |
| 1604 | if (!file || file.type !== "editor") return; |
| 1605 | const hasTop = typeof file.lastScrollTop === "number"; |
| 1606 | const hasLeft = typeof file.lastScrollLeft === "number"; |
| 1607 | if (!hasTop && !hasLeft) return; |
| 1608 | |
| 1609 | const fileId = file.id; |
| 1610 | const top = hasTop ? file.lastScrollTop : undefined; |
| 1611 | const left = hasLeft ? file.lastScrollLeft : undefined; |
| 1612 | |
| 1613 | const apply = () => { |
| 1614 | if (manager.activeFile?.id !== fileId) return; |
| 1615 | suppressCursorReveal(450); |
| 1616 | setScrollPosition(editor, top, left); |
| 1617 | |
| 1618 | const scroller = editor?.scrollDOM; |
| 1619 | if (scroller) { |
| 1620 | if (hasTop) lastScrollTop = scroller.scrollTop; |
| 1621 | if (hasLeft) lastScrollLeft = scroller.scrollLeft; |
| 1622 | lockScrollbarScrollPosition( |
| 1623 | { |
| 1624 | top: hasTop ? scroller.scrollTop : undefined, |
| 1625 | left: hasLeft ? scroller.scrollLeft : undefined, |
| 1626 | }, |
| 1627 | 450, |
| 1628 | ); |
| 1629 | } |
| 1630 | }; |
| 1631 | |
| 1632 | apply(); |
| 1633 | scrollRestoreFrame = requestAnimationFrame(() => { |
| 1634 | scrollRestoreFrame = 0; |
| 1635 | apply(); |
| 1636 | scrollRestoreNestedFrame = requestAnimationFrame(() => { |
| 1637 | scrollRestoreNestedFrame = 0; |
| 1638 | apply(); |
| 1639 | }); |
| 1640 | }); |
| 1641 | scrollRestoreTimeout = setTimeout(() => { |
| 1642 | scrollRestoreTimeout = 0; |
| 1643 | apply(); |
| 1644 | }, 120); |
| 1645 | } |
| 1646 | |
| 1647 | function cancelPendingScrollRestore() { |
| 1648 | if (scrollRestoreFrame) { |
no test coverage detected