Saving re-seats the native tab body (the chip's dirty mark clears, the change
gutter refreshes), and a scroller that is detached from the document comes back
with `scrollTop` 0 — scroll position is carried neither by React state nor by
the DOM node, so the edit surface needed its own memory. The preview already
kept one for the same reason (its save-then-reload collapses the container);
the editor relied on the view never being re-seated, which saving breaks.
Mirror the preview's pattern for the CodeMirror scroller:
- record the position on the scroller's scroll event, keyed per session + path,
with a guard so the restore's own write is not recorded as the user's;
- restore on the save edges (`saving → saved`, the change-gutter refresh, the
mode gate), and after every reveal re-measure moved from #890's family;
- skip when the document fits (no meaningful position) or when the position did
not change.
On top of the upstream `dev` line that already carries #859 and #890.
The native right sidebar parks a `keepMounted` tab body through the host's
`retainTab` path, which moves the body into a hidden seat and back. Moving a
node never changes its border box, so the `ResizeObserver` added in #837
(d3df20e / db563ca) is never called for that path: a CodeMirror view created
while its host was hidden keeps the zero-sized viewport it measured, and the
editor stays visually blank — gutter line numbers drawn, document body empty —
until the tab is remounted. Observed on DSH 0.2.0-rc.2 + the Electron shell
with a `.yaml` file opened from the file tree while another tab was active: the
buffer holds the text (select-all copies it), only the paint is missing.
Three additive recoveries, next to the existing measure:
- `IntersectionObserver` on the host — reports the reveal itself, so a body
that was merely moved is re-measured (the box need not change).
- a `requestAnimationFrame` follow-up after mount — a reveal that lands in the
mount's own frame happens after CodeMirror's first measure read a zero box.
- `visibilitychange` / `window resize` — the document-level equivalents.
A non-intersecting report spends nothing, so pane scrolling does not queue
measures. `tests/text-editor-visibility.spec.tsx` gains a case for the
size-preserving reveal (and pins that the invisible report is ignored); the
existing ResizeObserver cases are unchanged.