From d7ecbdcc1d7c4a92f6b3b581c32d5252b85e31ee Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 4 Jan 2022 14:55:16 -0800 Subject: [PATCH] Add unit test showing problem with serialization of undo ops --- crates/language/src/tests.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/language/src/tests.rs b/crates/language/src/tests.rs index 4db5e788f8..b09be21d90 100644 --- a/crates/language/src/tests.rs +++ b/crates/language/src/tests.rs @@ -780,6 +780,21 @@ async fn test_empty_diagnostic_ranges(mut cx: gpui::TestAppContext) { }); } +#[gpui::test] +fn test_serialization(cx: &mut gpui::MutableAppContext) { + let buffer1 = cx.add_model(|cx| { + let mut buffer = Buffer::new(0, "abc", cx); + buffer.edit([3..3], "DE", cx); + buffer.undo(cx); + buffer + }); + assert_eq!(buffer1.read(cx).text(), "abc"); + + let message = buffer1.read(cx).to_proto(); + let buffer2 = cx.add_model(|cx| Buffer::from_proto(1, message, None, cx).unwrap()); + assert_eq!(buffer2.read(cx).text(), "abc"); +} + fn chunks_with_diagnostics( buffer: &Buffer, range: Range,