Skip to content

[Bug] Undo (Ctrl+Z) in Split View uses incorrect offsets, causing document corruption #167

Description

@kyww

Description

Performing an undo action (Ctrl+Z) while editing a code block in Split View results in document corruption. While the UI panels remain visually synchronized, the undo operation appears to use incorrect positional offsets. This leads to the editor deleting or replacing the wrong range of text across both views.

Environment

  • OS: Windows 11
  • Ferrite version: v0.3.0
  • Installation method: pre-built binary

Steps to Reproduce

  1. Create a new Markdown file.
  2. Insert a Code Block containing placeholder text.
  3. Open Split View.
  4. In the right-hand panel, click Edit on the code block and append additional text.
  5. Press Ctrl + Z to undo the change.

Expected Behavior

The undo action should target the specific character offsets of the recent edit, reverting the text cleanly in both panels.

Actual Behavior

The document content becomes corrupted. Although both panels remain synchronized with each other, the "undo" operation applies to the wrong position in the buffer, mangling the Markdown structure or deleting unintended text.

Additional Context

Suspected Cause

The issue is likely not a synchronization failure between panels, but a state-tracking error. The editor likely fails to translate the local offsets of the Split View editor back to the global offsets of the primary Markdown buffer during an undo event.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.3.1bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions