Remove ReadView
and UpdateView
traits
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
a6115d9330
commit
c165fb9be5
12 changed files with 160 additions and 183 deletions
|
@ -2715,7 +2715,7 @@ impl Editor {
|
|||
title: String,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<()> {
|
||||
let replica_id = this.read_with(&cx, |this, cx| this.replica_id(cx));
|
||||
let replica_id = this.read_with(&cx, |this, cx| this.replica_id(cx))?;
|
||||
|
||||
let mut entries = transaction.0.into_iter().collect::<Vec<_>>();
|
||||
entries.sort_unstable_by_key(|(buffer, _)| {
|
||||
|
@ -2732,7 +2732,7 @@ impl Editor {
|
|||
.buffer()
|
||||
.read(cx)
|
||||
.excerpt_containing(editor.selections.newest_anchor().head(), cx)
|
||||
});
|
||||
})?;
|
||||
if let Some((_, excerpted_buffer, excerpt_range)) = excerpt {
|
||||
if excerpted_buffer == *buffer {
|
||||
let all_edits_within_excerpt = buffer.read_with(&cx, |buffer, _| {
|
||||
|
@ -5814,7 +5814,7 @@ impl Editor {
|
|||
buffer_highlights
|
||||
.next()
|
||||
.map(|highlight| highlight.start.text_anchor..highlight.end.text_anchor)
|
||||
})
|
||||
})?
|
||||
};
|
||||
if let Some(rename_range) = rename_range {
|
||||
let rename_buffer_range = rename_range.to_offset(&snapshot);
|
||||
|
|
|
@ -5673,8 +5673,8 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
|||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
follower_1.read_with(cx, Editor::text),
|
||||
leader.read_with(cx, Editor::text)
|
||||
follower_1.read_with(cx, |editor, cx| editor.text(cx)),
|
||||
leader.read_with(cx, |editor, cx| editor.text(cx))
|
||||
);
|
||||
update_message.borrow_mut().take();
|
||||
|
||||
|
@ -5697,8 +5697,8 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
|||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
follower_2.read_with(cx, Editor::text),
|
||||
leader.read_with(cx, Editor::text)
|
||||
follower_2.read_with(cx, |editor, cx| editor.text(cx)),
|
||||
leader.read_with(cx, |editor, cx| editor.text(cx))
|
||||
);
|
||||
|
||||
// Remove some excerpts.
|
||||
|
@ -5725,8 +5725,8 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
|||
.unwrap();
|
||||
update_message.borrow_mut().take();
|
||||
assert_eq!(
|
||||
follower_1.read_with(cx, Editor::text),
|
||||
leader.read_with(cx, Editor::text)
|
||||
follower_1.read_with(cx, |editor, cx| editor.text(cx)),
|
||||
leader.read_with(cx, |editor, cx| editor.text(cx))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ impl FollowableItem for Editor {
|
|||
== editor.read(cx).buffer.read(cx).as_singleton().as_ref();
|
||||
ids_match || singleton_buffer_matches
|
||||
})
|
||||
});
|
||||
})?;
|
||||
|
||||
let editor = if let Some(editor) = editor {
|
||||
editor
|
||||
|
|
|
@ -57,7 +57,7 @@ impl<'a> EditorTestContext<'a> {
|
|||
|
||||
pub fn editor<F, T>(&self, read: F) -> T
|
||||
where
|
||||
F: FnOnce(&Editor, &AppContext) -> T,
|
||||
F: FnOnce(&Editor, &ViewContext<Editor>) -> T,
|
||||
{
|
||||
self.editor.read_with(self.cx, read)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue