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
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()andmark_pristine()toDocument, implementing them inTextDocumentutilizing the existingBuffer::is_pristineandBuffer::set_pristine.Does this seem optimal?
I can make the changes.
Status Update:
Ready for review