Merge MutableAppContext into AppContext

There may have been a good reason for the difference at some point, or I was
still learning Rust. But now it's just &mut AppContext vs &AppContext.
This commit is contained in:
Nathan Sobo
2023-04-06 15:49:03 -06:00
parent dd00966cc6
commit de9bf6dfbd
112 changed files with 882 additions and 1041 deletions
+3 -3
View File
@@ -1015,7 +1015,7 @@ mod tests {
}
#[gpui::test]
fn test_basic_blocks(cx: &mut gpui::MutableAppContext) {
fn test_basic_blocks(cx: &mut gpui::AppContext) {
cx.set_global(Settings::test(cx));
let family_id = cx
@@ -1191,7 +1191,7 @@ mod tests {
}
#[gpui::test]
fn test_blocks_on_wrapped_lines(cx: &mut gpui::MutableAppContext) {
fn test_blocks_on_wrapped_lines(cx: &mut gpui::AppContext) {
cx.set_global(Settings::test(cx));
let family_id = cx
@@ -1241,7 +1241,7 @@ mod tests {
}
#[gpui::test(iterations = 100)]
fn test_random_blocks(cx: &mut gpui::MutableAppContext, mut rng: StdRng) {
fn test_random_blocks(cx: &mut gpui::AppContext, mut rng: StdRng) {
cx.set_global(Settings::test(cx));
let operations = env::var("OPERATIONS")
+7 -7
View File
@@ -1214,7 +1214,7 @@ mod tests {
use Bias::{Left, Right};
#[gpui::test]
fn test_basic_folds(cx: &mut gpui::MutableAppContext) {
fn test_basic_folds(cx: &mut gpui::AppContext) {
cx.set_global(Settings::test(cx));
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
@@ -1287,7 +1287,7 @@ mod tests {
}
#[gpui::test]
fn test_adjacent_folds(cx: &mut gpui::MutableAppContext) {
fn test_adjacent_folds(cx: &mut gpui::AppContext) {
cx.set_global(Settings::test(cx));
let buffer = MultiBuffer::build_simple("abcdefghijkl", cx);
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
@@ -1334,7 +1334,7 @@ mod tests {
}
#[gpui::test]
fn test_overlapping_folds(cx: &mut gpui::MutableAppContext) {
fn test_overlapping_folds(cx: &mut gpui::AppContext) {
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx);
let mut map = FoldMap::new(buffer_snapshot.clone()).0;
@@ -1350,7 +1350,7 @@ mod tests {
}
#[gpui::test]
fn test_merging_folds_via_edit(cx: &mut gpui::MutableAppContext) {
fn test_merging_folds_via_edit(cx: &mut gpui::AppContext) {
cx.set_global(Settings::test(cx));
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
@@ -1374,7 +1374,7 @@ mod tests {
}
#[gpui::test]
fn test_folds_in_range(cx: &mut gpui::MutableAppContext) {
fn test_folds_in_range(cx: &mut gpui::AppContext) {
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx);
let mut map = FoldMap::new(buffer_snapshot.clone()).0;
@@ -1401,7 +1401,7 @@ mod tests {
}
#[gpui::test(iterations = 100)]
fn test_random_folds(cx: &mut gpui::MutableAppContext, mut rng: StdRng) {
fn test_random_folds(cx: &mut gpui::AppContext, mut rng: StdRng) {
cx.set_global(Settings::test(cx));
let operations = env::var("OPERATIONS")
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
@@ -1656,7 +1656,7 @@ mod tests {
}
#[gpui::test]
fn test_buffer_rows(cx: &mut gpui::MutableAppContext) {
fn test_buffer_rows(cx: &mut gpui::AppContext) {
let text = sample_text(6, 6, 'a') + "\n";
let buffer = MultiBuffer::build_simple(&text, cx);
@@ -578,7 +578,7 @@ impl<'a> Iterator for SuggestionBufferRows<'a> {
mod tests {
use super::*;
use crate::{display_map::fold_map::FoldMap, MultiBuffer};
use gpui::MutableAppContext;
use gpui::AppContext;
use rand::{prelude::StdRng, Rng};
use settings::Settings;
use std::{
@@ -587,7 +587,7 @@ mod tests {
};
#[gpui::test]
fn test_basic(cx: &mut MutableAppContext) {
fn test_basic(cx: &mut AppContext) {
let buffer = MultiBuffer::build_simple("abcdefghi", cx);
let buffer_edits = buffer.update(cx, |buffer, _| buffer.subscribe());
let (mut fold_map, fold_snapshot) = FoldMap::new(buffer.read(cx).snapshot(cx));
@@ -632,7 +632,7 @@ mod tests {
}
#[gpui::test(iterations = 100)]
fn test_random_suggestions(cx: &mut MutableAppContext, mut rng: StdRng) {
fn test_random_suggestions(cx: &mut AppContext, mut rng: StdRng) {
cx.set_global(Settings::test(cx));
let operations = env::var("OPERATIONS")
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
+4 -4
View File
@@ -578,7 +578,7 @@ mod tests {
use rand::{prelude::StdRng, Rng};
#[gpui::test]
fn test_expand_tabs(cx: &mut gpui::MutableAppContext) {
fn test_expand_tabs(cx: &mut gpui::AppContext) {
let buffer = MultiBuffer::build_simple("", cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx);
let (_, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
@@ -591,7 +591,7 @@ mod tests {
}
#[gpui::test]
fn test_long_lines(cx: &mut gpui::MutableAppContext) {
fn test_long_lines(cx: &mut gpui::AppContext) {
let max_expansion_column = 12;
let input = "A\tBC\tDEF\tG\tHI\tJ\tK\tL\tM";
let output = "A BC DEF G HI J K L M";
@@ -641,7 +641,7 @@ mod tests {
#[gpui::test]
fn test_long_lines_with_character_spanning_max_expansion_column(
cx: &mut gpui::MutableAppContext,
cx: &mut gpui::AppContext,
) {
let max_expansion_column = 8;
let input = "abcdefg⋯hij";
@@ -657,7 +657,7 @@ mod tests {
}
#[gpui::test(iterations = 100)]
fn test_random_tabs(cx: &mut gpui::MutableAppContext, mut rng: StdRng) {
fn test_random_tabs(cx: &mut gpui::AppContext, mut rng: StdRng) {
let tab_size = NonZeroU32::new(rng.gen_range(1..=4)).unwrap();
let len = rng.gen_range(0..30);
let buffer = if rng.gen() {
+2 -2
View File
@@ -7,7 +7,7 @@ use crate::MultiBufferSnapshot;
use gpui::{
fonts::{FontId, HighlightStyle},
text_layout::LineWrapper,
Entity, ModelContext, ModelHandle, MutableAppContext, Task,
AppContext, Entity, ModelContext, ModelHandle, Task,
};
use language::{Chunk, Point};
use lazy_static::lazy_static;
@@ -79,7 +79,7 @@ impl WrapMap {
font_id: FontId,
font_size: f32,
wrap_width: Option<f32>,
cx: &mut MutableAppContext,
cx: &mut AppContext,
) -> (ModelHandle<Self>, WrapSnapshot) {
let handle = cx.add_model(|cx| {
let mut this = Self {