Implementing split view phases 3-7 for Token editor
Based on the attached files, here's the context for Phase 3+:
Current State
Phase 1-2 Complete:
EditorAreawithsingle_document()migration helpercompute_layout(),group_at_point(),splitter_at_point()- 7 unit tests in editor_area.rs
Phase 3: Update AppModel
Goal: Replace AppModel.document + AppModel.editor with AppModel.editor_area
Key changes needed:
AppModel struct (mod.rs:51-66): Replace fields
// FROM: pub document: Document, pub editor: EditorState, // TO: pub editor_area: EditorArea,Add accessor methods to AppModel:
focused_document()→&Documentfocused_document_mut()→&mut Documentfocused_editor()→&EditorStatefocused_editor_mut()→&mut EditorState
Update all call sites - Currently ~100+ references to
model.documentandmodel.editorin:update.rs(most complex - cursor movement, editing)main.rs(rendering, input handling)tests/common/mod.rs(test helpers)
Migration path - Use
EditorArea::single_document()inAppModel::new()
Phase 4: Messages
Add to messages.rs:
pub enum LayoutMsg {
SplitGroup { group_id: GroupId, direction: SplitDirection },
CloseGroup(GroupId),
FocusGroup(GroupId),
MoveTab { tab_id: TabId, to_group: GroupId },
}
Wire into Msg enum and update().
Recommended Approach
Start Phase 3 with TDD:
- Update
tests/common/mod.rshelper first (simpler) - Add accessor methods to AppModel
- Update
AppModel::new()to use EditorArea - Fix compilation errors in update.rs
- Fix compilation errors in main.rs
- Run
make testto verify
Want me to begin Phase 3 implementation?
Phase 3 Complete!
Summary
Successfully migrated AppModel from direct document/editor fields to the new EditorArea architecture:
Changes Made
AppModel struct (mod.rs):
- Replaced
document: Documentandeditor: EditorStatewitheditor_area: EditorArea - Added accessor methods:
document(),document_mut(),editor(),editor_mut() - Updated
new()to useEditorArea::single_document()
- Replaced
status_bar.rs: Updated
sync_status_bar()to use accessor methodsupdate.rs: ~300+ changes from
model.editor.*→model.editor().*/model.editor_mut().*main.rs: Similar accessor method updates for rendering and input
tests/common/mod.rs: Updated test helpers to construct
EditorAreaAll test files (7 files, ~304 fixes): Updated to use accessor methods
Bug fix: Fixed
DeleteLinelogic for edge cases with trailing newlines
Test Results
- 253 tests passing (same count as before)
- Build succeeds
- All existing functionality preserved
Next Steps (Phases 4-7)
- Phase 4: Add
LayoutMsgenum for split/close/focus operations - Phase 5: Render multiple groups, tab bars, splitters
- Phase 6: Document synchronization across views
- Phase 7: Keyboard shortcuts (Cmd+, Cmd+W, etc.)
Phase 4 Complete!
Summary
Successfully implemented the LayoutMsg message system for split views:
New Messages (messages.rs)
Added LayoutMsg enum with operations:
SplitFocused(direction)/SplitGroup { group_id, direction }- Split groupsCloseGroup(id)/CloseFocusedGroup- Close groupsFocusGroup(id)/FocusNextGroup/FocusPrevGroup/FocusGroupByIndex(n)- Focus navigationMoveTab { tab_id, to_group }- Move tabs between groupsCloseTab(id)/CloseFocusedTab- Close tabsNextTab/PrevTab/SwitchToTab(n)- Tab navigation
New Functions (update.rs)
update_layout()- Main handler dispatching to helperssplit_focused_group()/split_group()- Create new groups with same documentinsert_split_in_layout()- Update layout tree with new splitsclose_group()/remove_group_from_layout()- Remove groups and collapse treecollect_group_ids()- Traverse layout treefocus_adjacent_group()- Cycle through groupsmove_tab()/close_tab()- Tab management
Tests (tests/layout.rs)
17 new tests covering:
- Split operations (horizontal, vertical, multiple)
- Close group (last group protection, cleanup, layout collapse)
- Focus operations (direct, next/prev, by index)
- Tab navigation
- Integration: edits affecting shared document
Test Results
- 270 tests passing (up from 253)
- All existing tests still pass
Next Steps
- Phase 5: Rendering - multi-group rendering, tab bars, splitters
- Phase 6: Document synchronization
- Phase 7: Keyboard shortcuts
Split View Implementation Complete! 🎉
All 7 phases of the Split View feature are now complete:
Summary
| Phase | Status | Description |
|---|---|---|
| Phase 1 | ✅ | Core Data Structures - ID types, EditorArea, Tab, EditorGroup, LayoutNode |
| Phase 2 | ✅ | Layout System - compute_layout(), group_at_point(), splitter hit testing |
| Phase 3 | ✅ | Update AppModel - Replaced Document/EditorState with EditorArea, accessor methods |
| Phase 4 | ✅ | Messages - LayoutMsg enum, split/close/focus operations, 17 tests |
| Phase 5 | ✅ | Rendering - Multi-group rendering, tab bars, splitters, focus indicators |
| Phase 6 | ✅ | Document Sync - Shared document architecture (cursor adjustment deferred) |
| Phase 7 | ✅ | Keyboard Shortcuts - Cmd+\, Cmd+W, Cmd+1/2/3/4, Ctrl+Tab |
New Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Cmd+\ / Ctrl+\ |
Split horizontally |
Cmd+Shift+\ / Ctrl+Shift+\ |
Split vertically |
Cmd+W / Ctrl+W |
Close tab/group |
Cmd+1/2/3/4 / Ctrl+1/2/3/4 |
Focus group by index |
Ctrl+Tab |
Focus next group |
Ctrl+Shift+Tab |
Focus previous group |
Test Results
- 293 tests passing (up from 253 at start)
- 40 new tests added (17 layout + 23 renderer)
Key Files Modified
src/model/editor_area.rs- Core split view data structuressrc/model/mod.rs- AppModel with EditorArea integrationsrc/messages.rs- LayoutMsg enumsrc/update.rs- update_layout() and helper functionssrc/theme.rs- TabBarTheme, SplitterThemesrc/main.rs- Multi-group rendering and keyboard shortcutstests/layout.rs- 17 layout operation tests
The Split View feature is now complete. Looking at the ROADMAP, here are the next options:
Recommended Next Steps
Move Split View to "Recently Completed" - Update ROADMAP structure
Choose next feature from the planned list:
- Occurrence Selection (Phase 9) -
Cmd+Jto select next match (JetBrains-style) - Expand/Shrink Selection - Progressive selection with Option+Up/Down
- File Dropping - Drag-and-drop files to open
- Workspace Management - CLI args for multiple files/directories
- Occurrence Selection (Phase 9) -
Polish items (deferred from Split View):
- Cursor adjustment when other views edit
- Splitter drag resize (currently splitters render but aren't draggable)
- Tab drag-and-drop between groups
My Recommendation
Occurrence Selection (Cmd+J) is a high-value feature that builds on the existing multi-cursor infrastructure and is commonly expected in modern editors.
Alternatively, File Dropping would make the editor more usable for daily work.
Which would you like to tackle next?