Repository navigation
Keep cursor and page motion out of folded Org drawers - #340
Conversation
|
I pushed the ideal follow-up in d97107e and rebased the complete PR onto current main.\n\nThe root problem was broader than Org folding: source-newline counts are not valid display-row measurements across invisibility, selective display, or replacing display properties. The original preflight workaround also did not protect the post-layout retry, which could still move window-start into an unmeasured fold.\n\nThe follow-up now:\n\n- uses a typed SourceLineEstimate versus DisplayRowsRequired contract in both pre-layout selection and post-layout retry;\n- advances through canonical measured display rows whenever source can collapse;\n- centralizes visible, hidden, and hidden-with-ellipsis classification for Lisp, motion, and layout;\n- preserves the GNU Emacs distinction between window display motion and nil-window column scans;\n- retains the newer main-branch invisibility-origin model for GNU boundary overlay strings;\n- scopes collapse detection to effective properties in the relevant range, so harmless overlays do not exhaust the visibility retry limit;\n- adds regressions for large folds, replacing display spans, ellipsis-bearing column semantics, and distant motion with a face-only overlay.\n\nGNU reference for the window-sensitive invisible-source behavior: https://github.com/emacs-mirror/emacs/blob/master/src/indent.c\n\nAfter resolving the rebase conflicts, I verified 8 focused layout tests, 15 focused neovm-core motion tests, cargo check for neovm-core and neomacs-layout-engine, cargo fmt --all -- --check, and git diff --check. The pre-push workspace check also passed. |
Measure point visibility across invisible runs before recentering a window. This prevents large folded Org drawers from being counted as visible logical rows, which could move the window start into LOGBOOK contents and make cursor and page motion bounce.
Org folds and other display properties can collapse many source lines into one rendered row. The PR's preflight workaround approximated glyph widths and protected only the initial viewport decision; the post-layout visibility retry could still count hidden newlines, move window-start into an unmeasured fold, and accept an invalid viewport. Introduce ForwardScrollMeasurement as the typed contract shared by source preflight and visibility retry. Source-line estimates remain available for monotonic text, while effective invisibility, selective display, and replacing display properties require progress through rows produced by the canonical display walk. Make the collapse scan range- and semantics-aware so an unrelated face overlay does not degrade a distant jump into more than the retry limit of screen-sized layouts. Centralize GNU's visible/hidden/hidden-with-ellipsis result in the Invisibility enum and reuse it from Lisp, editor motion, and layout. Preserve GNU skip_invisible semantics explicitly with InvisibleRunContext: display motion elides both hidden forms, whereas current-column and move-to-column count source text for ellipsis-bearing invisibility when no window is supplied. Add regressions for preflight over folded and replacing spans, post-layout retries across a large fold, distant motion with a harmless overlay, and the GNU-compatible column/motion distinction. These tests failed before the corresponding fixes and now exercise the public layout and Lisp seams.
a7e4412 to
d97107e
Compare
Collapsed Org drawers could still affect display motion as if their hidden source lines were visible. Cursor movement could enter a LOGBOOK, expose its contents, recenter the viewport inside the drawer, or make Page Up return to its previous position.
Treat both ordinary invisible runs and ellipsis-bearing runs as hidden during vertical motion. The viewport preflight now also measures point visibility across folded runs before deciding to recenter, so a large hidden LOGBOOK counts as an ellipsis instead of hundreds of visible lines.