Skip to content

Eliminate inconsistent cursor state across document revisions #1058

Description

@Third-Thing

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions