diff --git a/src/doc.rs b/src/doc.rs index dbf1e41..32284b4 100644 --- a/src/doc.rs +++ b/src/doc.rs @@ -116,7 +116,7 @@ impl Doc { pub fn observe(&mut self, py: Python<'_>, f: PyObject) -> PyResult> { let sub = self.doc .observe_transaction_cleanup(move |txn, event| { - if event.before_state != event.after_state { + if !event.delete_set.is_empty() || event.before_state != event.after_state { Python::with_gil(|py| { let event = TransactionEvent::new(event, txn); if let Err(err) = f.call1(py, (event,)) { diff --git a/tests/test_doc.py b/tests/test_doc.py index e54f3b1..97c2437 100644 --- a/tests/test_doc.py +++ b/tests/test_doc.py @@ -191,3 +191,15 @@ def test_empty_update(): doc["text"] # empty updates should not emit an event assert not events + + +def test_not_empty_update(): + doc = Doc() + doc["text"] = text = Text() + events = [] + sub = doc.observe(partial(callback, events)) # noqa: F841 + + text += "helloo" + events.clear() + del text[5] + assert events