Skip to content

Enable undo-aware dirty tracking for TextDocument #1054

Description

@Third-Thing

Goal: Enable application code to query whether a document has unsaved changes, so that developers can implement save-on-close and discard-confirmation without tracking dirty state themselves.

Strategy: Add is_dirty() and mark_pristine() to Document, implementing them in TextDocument utilizing the existing Buffer::is_pristine and Buffer::set_pristine.

fn is_dirty(&self) -> bool {
    !self.buffer.with_untracked(Buffer::is_pristine)
}

fn mark_pristine(&self) {
    self.buffer.update(Buffer::set_pristine);
    self.update_cache_rev();
}

Does this seem optimal?

I can make the changes.


Status Update: Ready for review

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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