Repository navigation
add support for split editors (two views of one document) - #18460
Conversation
Adds an editor split to source tabs: a second Ace view of the same document, side by side or stacked, sharing the document and undo history while keeping selection, scroll position, and folds per-view. - new commands: splitEditorRight, splitEditorDown, removeEditorSplit, toggleEditorSplit, focusOtherEditorSplit (View > Split Editor), plus a toolbar menu button - split state is stored in the editorSplit document property and restored when the document is reopened - selection-driven commands (run line/selection, rstudioapi editor context, status bar position) follow the focused view; document-level behavior (persistence, markers, chunk output, breakpoints) stays on the primary view - splits are a source-mode feature; the commands are disabled while the visual editor is active Addresses #2129
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
When a source editor already holds focus and its document has an active split, the activateSource command (Ctrl+1) now moves focus to the other view instead of doing nothing, giving keyboard users a toggle between the views without a new binding. Addresses #2129
… button Replaces the hand-drawn placeholder with the splitscreen_right icon from Google's Material Symbols (Apache 2.0; added to NOTICE), recolored to match the neighboring toolbar icons. Addresses #2129
Regenerates the icon at 40x36 (the standard 2x toolbar button size; the previous 22x20 matched the outline toggle, which is an outlier) with the glyph scaled to fill the button, and increases the ink density so the dark-theme inversion produces a brighter icon. Addresses #2129
Scales the glyph ink to 18x14 (logical) within the standard 40x36 toolbar icon canvas, so the icon reads as a split editor window and carries the same whitespace as its neighbors. Addresses #2129
The glyph now occupies 14x11 (logical) of the 20x18 button, in line with the ink coverage of the other toolbar icons (roughly 9-12 wide by 12-16 tall); the previous 18x14 filled the button nearly edge to edge, which read as oversized next to its neighbors. Addresses #2129
The filled Material glyph read as a solid blob next to the line-art toolbar neighbors, especially under the dark-theme invert filter. Replace it with a hand-drawn frame-plus-divider at the same ink geometry (28x22 physical in a 40x36 canvas), and drop the Material Symbols NOTICE entry since the icon is no longer derived from it.
Code review findingsActionable items from an automated multi-agent review. Findings 1, 2, 4, 5, 6 were traced through the code by hand; 10 and 11 are code-path arguments that need a running IDE to confirm. Critical
Important
Tests
Suggestions
|
RStudio modes bind their code model to the session they are created with, and EditSession.setEditorMode reuses a mode whose constructor matches -- so a cloned session sharing the primary's mode object kept a code model pointed at the primary session forever (Enter in the split view indented against the primary view's cursor). Create the clone with a plain text mode instead, so setFileType() builds a clone-bound mode. Also delegate the clone's mergeUndoDeltas flag to the source session: the shared UndoManager reads the flag from whichever session reports a delta first (the primary), so typing in the split view would otherwise start a new undo group on every keystroke.
- tear down the split view from TextEditingTarget.onDismiss(), so closing a split tab releases the ~40 pref bindings registered against the UserPrefs singleton (and the editors they capture) - detach the split executor's last-executed selection anchors when the split is removed; they attach to the shared document and leaked - restore focus after removing a split only when an editor view held it (captured before teardown detaches the views), so removing the split from e.g. the Console no longer steals focus - have focusOtherEditorSplit() report whether it moved focus, so Ctrl+1 falls through to normal source activation while a requested split is still waiting on layout instead of being swallowed - validate the editorSplit document property against the known values; stale or future values collapse to none instead of being memorized and reproduced by toggleEditorSplit - apply the soft wrap state after setFileType()/pref registration in ensureSplitEditor(); both reset the wrap limit range and clobbered the margin-column wrap - hide the split editor toolbar button in visual mode, where all of its menu commands are disabled - re-add the primary editor as the center widget only when returning to a single view, avoiding a redundant detach/attach cycle on right/down orientation switches - mention breakpoints in the Display primary/secondary note, and the primary-view Find/Replace limitation in NEWS
- assert split orientation via bounding boxes (right = side by side, down = stacked), and verify toggleEditorSplit restores a down split rather than the default right orientation - assert the primary view holds focus before the shared-undo loop, and that the original content survives it (guards against an over-undo) - make documentValue() throw instead of coalescing to '', so content assertions cannot pass vacuously without an active editor - add a close-while-split test (the suite otherwise always removes the split before closing) and a reload test covering the editorSplit property restore through the deferred-layout path
|
Worked through all 22 findings; each was verified against the code before acting. 19 applied across f111bf7, 565e10d, and f825bf6; the split-editor e2e suite passes (7/7) including the new coverage. Critical
Important
Tests (f825bf6)
Suggestions 18-20. Comment fixes applied as suggested (fold seeding wording, |
RStudio E2E - all platforms1 test(s) failed
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
The unscoped .ace_editor locator also matched the console, whose echoed writeAndOpenFile writeLines() fallback contains the marker text on Server. Scope the locator to the source panel, and give the post-reload view assertion the same budget as a file open (the restore is asynchronous and can exceed the default expect timeout on CI).
TextEditingTargetThemeHelper asserts a single ace_scroller under the editing target, which an active editor split violates; assertion-enabled builds (ant draft) throw AssertionError on the deferred split-restore path after a reload. Release builds already read the primary (first) view's styles either way.
quit() never returns to a prompt, so executeInConsole's default prompt-count wait stalled the browser for the full 30s sessionRestart timeout after every server run, with the session-ended overlay already on screen. Dispatch with wait:false; the overlay wait that follows is the completion signal.
Adds split editor support to the source pane: an editor tab can show a second view of its document, either side by side ("Split Editor Right") or stacked ("Split Editor Down"), so different parts of a file can be viewed and edited at the same time.
Behavior
Splitimplementation: the secondary view gets a clonedEditSessionover the sharedDocumentandUndoManager(sharing a single session is not possible, as Ace sessions own the selection and scroll state).splitEditorRight,splitEditorDown,removeEditorSplit,toggleEditorSplit(re-enables the most recent orientation), andfocusOtherEditorSplitfor keyboard navigation between the views. All are user-bindable, appear under View > Split Editor, and are also reachable from a new editor toolbar menu button. When a source editor already holds focus and the document is split,activateSource(Ctrl+1) also toggles focus between the two views.editorSplit), so it is restored per-document when the IDE reloads.rstudioapi::getEditorContext()and friends, and the status bar cursor position and scope. Everything bound to the document itself (persistence, autosave, lint/spelling/debug markers, chunk output, navigation, find/replace) stays on the primary view; the distinction is documented inTextEditingTarget.Display.AceEditorwith its own line-widget manager, so chunk-output mirroring can be added later without rework.Notes for reviewers
Selection) and the background highlighter pointing at a dead session. Here the cloned session is installed inside theAceEditorWidgetconstructor, before any session handlers bind.UndoManageracross two sessions over one document is safe: both sessions report the same delta object, andUndoManager.adddedupes it (delta == this.$lastDelta).TextEditingTargetPrefsHelper.registerPrefs()(the same path visual-mode chunk editors use), so editor prefs -- including Vim/Emacs keybindings -- apply to both views, and completion contexts are forwarded from the editing target.Includes Playwright coverage (
e2e/rstudio/tests/panes/editor/split_editor.test.ts) for document/undo sharing across views, per-view cursors, focus switching, split state toggling, and run-line following the focused view.Fixes #2129.