The shared-editor crash issue (#934) exposed a broader API problem.
TextDocument currently has three edit paths:
receive_char
do_edit
edit / edit_single
The first two are editor-aware. The third mutates the document directly without any Editor or shared-group context.
That leads to several problems:
- programmatic edits can leave a single editor with a stale cursor
- editors attached to the same document can keep stale cursors after another editor modifies the text
edit / edit_single do not record cursor_before / cursor_after, so undo lacks full editor state
Proposal
Deprecate:
Document::edit(...)
Document::edit_single(...)
Make editor-aware editing the primary API:
Editor::edit(...)
EditorGroup::edit(...)
If multiple editors share one document, EditorGroup gives one place to coordinate:
- attached editors
- cursor remapping
- undo-related editor state
- future shared-edit behavior
The reported crashes, plus the editor example’s intentional suppression of undo in one shared editor, demonstrate the need for this.
Status Update: Ready for review
The shared-editor crash issue (#934) exposed a broader API problem.
TextDocumentcurrently has three edit paths:receive_chardo_editedit/edit_singleThe first two are editor-aware. The third mutates the document directly without any
Editoror shared-group context.That leads to several problems:
edit/edit_singledo not recordcursor_before/cursor_after, so undo lacks full editor stateProposal
Deprecate:
Document::edit(...)Document::edit_single(...)Make editor-aware editing the primary API:
Editor::edit(...)EditorGroup::edit(...)If multiple editors share one document,
EditorGroupgives one place to coordinate:The reported crashes, plus the editor example’s intentional suppression of undo in one shared editor, demonstrate the need for this.
Status Update:
Ready for review