Preserve ancestor scroll positions when focusing the native edit context#14696
Preserve ancestor scroll positions when focusing the native edit context#14696nstrayer wants to merge 4 commits into
Conversation
|
E2E Tests 🚀 |
PETE's assessment 🧪Verdict: 🟢 Adequate -- The bug-fix adds a targeted e2e regression test that reproduces the exact click-on-wrong-line scenario, and the behavior (browser scroll-reveal during focus) genuinely requires the full app rendered to verify. What changed
Tests in this PR
Existing coverageThe new e2e test is the primary and correct coverage. I confirmed it exercises the fixed path: it establishes the precondition that the hidden input sits well below the scroll viewport ( Suggested additionsNone. Suggested tags (optional)None needed. The Deployment note (optional)None needed. This is precisely the kind of surface-sensitive fix where the PETE (Positron Extreme Test Experiment) - LLM-based test-coverage advisor, in pilot. Triggers on PR open and on |
|
@seeM Tagged you here because you did the work on the notebook scrolling on load so you may be more familiar with the scrolling mechanisms than normal! |
Fixes #14085
Fixes #14656
When a Positron notebook cell is taller than the viewport, clicking a line could place the cursor on the wrong line (#14085) and/or yank the scroll position to the top of the cell (#14656). Both symptoms share one root cause: when Monaco focuses its hidden edit-context node during click handling, the browser tries to reveal that node by scrolling every scrollable ancestor. The node is parked at the editor's last cursor position, so in a long cell that reveal shifts the notebook's scroll container mid-click, desyncing Monaco's hit test from what is on screen.
The fix mirrors the guard the textarea input path has carried for years (
writeNativeTextAreaContentintextAreaEditContextInput.ts): save ancestor scroll positions, focus, restore. Three lines inFocusTracker.focus(), fenced per upstream-compatibility conventions.Why this is safe outside notebooks
scrollTopthat actually changed duringfocus(). In stock VS Code surfaces (editors, VS Code notebooks, lists) scrolling is synthetic --listView.tseven actively resets browser-initiated scrolls -- so the guard is a no-op there.editor.editContext, and the textarea mode has applied this exact guard globally for ~a decade. Any surface depending on the browser reveal would already be broken in textarea mode.Release Notes
New Features
Bug Fixes
Validation Steps
@:positron-notebooks
A new e2e regression test covers the long-cell scenario (
notebook-click-cursor-position.test.ts): it verifies the precondition that the hidden edit-context node is far outside the scroll viewport, clicks a line near the top of a 60-line cell, and asserts the cursor landed on that exact line. It fails without the fix and passes with it.Manual check: