Editor: ignore selection changes while reloading text !371

merged merged by cmc on 2026-10-19 20:06 UTC · krz/orgstar:archive-fold-crash into main

Discussion

cmc

Fixes a crash (stack overflow) on Archive Subtree in the Mac editor when a fold after the archived subtree covers the new end of the text, as with #+STARTUP: overview.

OrgEditor.update loads the new text before setting the mapped folds. Replacing the storage moves the caret to the new end; selectionChanged() found it inside a stale fold, jumped to the fold's old end, was clamped back to the same offset, and recursed. Selection changes are now skipped while isLoading; update sets the caret after the folds.

  • Regression test: BufferTests.updateRemovingTextBeforeAFold
  • Full swift test suite passes.