From 5164026238b42cde875c7ba67cdb8a89e6b2864b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 7 Sep 2021 22:10:01 -0600 Subject: [PATCH] Test rewraping on font size change --- zed/src/editor/display_map.rs | 15 +++++++++++++-- zed/src/editor/display_map/wrap_map.rs | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/zed/src/editor/display_map.rs b/zed/src/editor/display_map.rs index ffad1b9c795604efaa8f695c019ff797d2672ee3..16d4da79b4c6446fa02f42c10469297dc397ccb0 100644 --- a/zed/src/editor/display_map.rs +++ b/zed/src/editor/display_map.rs @@ -545,8 +545,8 @@ mod tests { let text = "one two three four five\nsix seven eight"; let buffer = cx.add_model(|cx| Buffer::new(0, text.to_string(), cx)); - let settings = watch::channel_with(settings).1; - let map = cx.add_model(|cx| DisplayMap::new(buffer.clone(), settings, wrap_width, cx)); + let (mut settings_tx, settings_rx) = watch::channel_with(settings); + let map = cx.add_model(|cx| DisplayMap::new(buffer.clone(), settings_rx, wrap_width, cx)); let snapshot = map.update(&mut cx, |map, cx| map.snapshot(cx)); assert_eq!( @@ -602,6 +602,17 @@ mod tests { snapshot.chunks_at(1).collect::(), "three four \nfive\nsix and \nseven eight" ); + + // Re-wrap on font size changes + settings_tx.borrow_mut().buffer_font_size += 3.; + + map.next_notification(&mut cx).await; + + let snapshot = map.update(&mut cx, |map, cx| map.snapshot(cx)); + assert_eq!( + snapshot.chunks_at(1).collect::(), + "three \nfour five\nsix and \nseven \neight" + ) } #[gpui::test] diff --git a/zed/src/editor/display_map/wrap_map.rs b/zed/src/editor/display_map/wrap_map.rs index 08219826b101c6b40fc1ea281669c887297bde4c..d648a052aab0c6fb4ffc626d803d47983568d3a7 100644 --- a/zed/src/editor/display_map/wrap_map.rs +++ b/zed/src/editor/display_map/wrap_map.rs @@ -175,6 +175,7 @@ impl WrapMap { { Ok(snapshot) => { self.snapshot = snapshot; + cx.notify(); } Err(wrap_task) => { self.background_task = Some(cx.spawn(|this, mut cx| async move {