(engine: Host)
| 729 | } |
| 730 | |
| 731 | async function openOnFirstEdit(engine: Host): Promise<void> { |
| 732 | const isTaken = () => isPaneOpen || hasAutoOpened |
| 733 | |
| 734 | if (isTaken()) { |
| 735 | return |
| 736 | } |
| 737 | |
| 738 | /** |
| 739 | * An ask after one that did not open the pane reads the repository again, |
| 740 | * so it waits like a read an edit or command causes. Asks made during the |
| 741 | * wait become one ask when it ends. |
| 742 | */ |
| 743 | if (isAutoOpenPending && timers.has('rest')) { |
| 744 | isOpenAskKept = true |
| 745 | void endOverdueRest(engine) |
| 746 | |
| 747 | return |
| 748 | } |
| 749 | |
| 750 | isOpenAskKept = false |
| 751 | |
| 752 | const closesBefore = personCloses |
| 753 | const preference = await engine.storeGet(Names.STORE_OPEN_KEY) |
| 754 | const isKeptOpen = preference === true |
| 755 | |
| 756 | const floor = isKeptOpen |
| 757 | ? Limits.OPEN_MIN_COLUMNS |
| 758 | : Limits.AUTO_OPEN_MIN_COLUMNS |
| 759 | |
| 760 | const hasRoom = |
| 761 | preference !== false && |
| 762 | model.isFullscreen === true && |
| 763 | columns !== null && |
| 764 | columns >= floor |
| 765 | |
| 766 | if (!hasRoom || isTaken()) { |
| 767 | return |
| 768 | } |
| 769 | |
| 770 | const isCheckpointed = await engine.isCheckpointing().catch(() => true) |
| 771 | |
| 772 | if (!isCheckpointed || isTaken()) { |
| 773 | return |
| 774 | } |
| 775 | |
| 776 | await pinBackend(engine) |
| 777 | |
| 778 | if (!backend || isTaken()) { |
| 779 | return |
| 780 | } |
| 781 | |
| 782 | const landedBefore = landed |
| 783 | const { epoch } = pin |
| 784 | |
| 785 | hasAutoOpened = true |
| 786 | |
| 787 | const outcome = await openPane(engine, 'auto_open', closesBefore).catch( |
| 788 | (): OpenOutcome.OpenOutcome => 'withdrawn', |
no test coverage detected