@@ -608,17 +608,11 @@ mod tests {
fn test_chunks_at(cx: &mut gpui::MutableAppContext) {
let text = sample_text(6, 6);
let buffer = cx.add_model(|cx| Buffer::new(0, text, cx));
- let map = cx.add_model(|cx| {
- DisplayMap::new(
- buffer.clone(),
- Settings {
- tab_size: 4,
- ..Settings::test(cx)
- },
- None,
- cx,
- )
+ let settings = watch::channel_with(Settings {
+ tab_size: 4,
+ ..Settings::test(cx)
});
+ let map = cx.add_model(|cx| DisplayMap::new(buffer.clone(), settings.1, None, cx));
buffer.update(cx, |buffer, cx| {
buffer.edit(
vec![
@@ -690,17 +684,13 @@ mod tests {
});
buffer.condition(&cx, |buf, _| !buf.is_parsing()).await;
- let map = cx.add_model(|cx| {
- DisplayMap::new(
- buffer,
- Settings {
- tab_size: 2,
- ..Settings::test(cx)
- },
- None,
- cx,
- )
+ let settings = cx.update(|cx| {
+ watch::channel_with(Settings {
+ tab_size: 2,
+ ..Settings::test(cx)
+ })
});
+ let map = cx.add_model(|cx| DisplayMap::new(buffer, settings.1, None, cx));
assert_eq!(
cx.update(|cx| highlighted_chunks(0..5, &map, &theme, cx)),
vec![
@@ -781,13 +771,15 @@ mod tests {
buffer.condition(&cx, |buf, _| !buf.is_parsing()).await;
let font_cache = cx.font_cache();
- let settings = Settings {
- tab_size: 4,
- buffer_font_family: font_cache.load_family(&["Courier"]).unwrap(),
- buffer_font_size: 16.0,
- ..cx.read(Settings::test)
- };
- let map = cx.add_model(|cx| DisplayMap::new(buffer, settings, Some(40.0), cx));
+ let settings = cx.update(|cx| {
+ watch::channel_with(Settings {
+ tab_size: 4,
+ buffer_font_family: font_cache.load_family(&["Courier"]).unwrap(),
+ buffer_font_size: 16.0,
+ ..Settings::test(cx)
+ })
+ });
+ let map = cx.add_model(|cx| DisplayMap::new(buffer, settings.1, Some(40.0), cx));
assert_eq!(
cx.update(|cx| highlighted_chunks(0..5, &map, &theme, cx)),
[
@@ -822,17 +814,11 @@ mod tests {
let text = "\n'a', 'α',\t'✋',\t'❎', '🍐'\n";
let display_text = "\n'a', 'α', '✋', '❎', '🍐'\n";
let buffer = cx.add_model(|cx| Buffer::new(0, text, cx));
- let map = cx.add_model(|cx| {
- DisplayMap::new(
- buffer.clone(),
- Settings {
- tab_size: 4,
- ..Settings::test(cx)
- },
- None,
- cx,
- )
+ let settings = watch::channel_with(Settings {
+ tab_size: 4,
+ ..Settings::test(cx)
});
+ let map = cx.add_model(|cx| DisplayMap::new(buffer.clone(), settings.1, None, cx));
let map = map.update(cx, |map, cx| map.snapshot(cx));
assert_eq!(map.text(), display_text);
@@ -866,17 +852,11 @@ mod tests {
fn test_tabs_with_multibyte_chars(cx: &mut gpui::MutableAppContext) {
let text = "✅\t\tα\nβ\t\n🏀β\t\tγ";
let buffer = cx.add_model(|cx| Buffer::new(0, text, cx));
- let map = cx.add_model(|cx| {
- DisplayMap::new(
- buffer.clone(),
- Settings {
- tab_size: 4,
- ..Settings::test(cx)
- },
- None,
- cx,
- )
+ let settings = watch::channel_with(Settings {
+ tab_size: 4,
+ ..Settings::test(cx)
});
+ let map = cx.add_model(|cx| DisplayMap::new(buffer.clone(), settings.1, None, cx));
let map = map.update(cx, |map, cx| map.snapshot(cx));
assert_eq!(map.text(), "✅ α\nβ \n🏀β γ");
assert_eq!(
@@ -933,17 +913,11 @@ mod tests {
#[gpui::test]
fn test_max_point(cx: &mut gpui::MutableAppContext) {
let buffer = cx.add_model(|cx| Buffer::new(0, "aaa\n\t\tbbb", cx));
- let map = cx.add_model(|cx| {
- DisplayMap::new(
- buffer.clone(),
- Settings {
- tab_size: 4,
- ..Settings::test(cx)
- },
- None,
- cx,
- )
+ let settings = watch::channel_with(Settings {
+ tab_size: 4,
+ ..Settings::test(cx)
});
+ let map = cx.add_model(|cx| DisplayMap::new(buffer.clone(), settings.1, None, cx));
assert_eq!(
map.update(cx, |map, cx| map.snapshot(cx)).max_point(),
DisplayPoint::new(1, 11)