I am reading the source code for the @codemirror/fold package, and I see that when the selection is inside the folded region, the effect is removed and the code is unfolded: fold/fold.ts at abc16e33ad27de487e92ac3510897b0665da346c · codemirror/fold · GitHub But I also noticed that when I move through the document using up and down arrows, the folded region are not unfolded, they are treated as single lines. Where is the code that does that? How is this implemented?
Cursor positions for vertical motion are found with
posAtCoords (since they also need to be robust in the face of different fonts, widgets, and Unicode complexities), which never returns positions inside replaced ranges.