Remove more references to 'model' in GPUI APIs (#23693)
Release Notes: - N/A
This commit is contained in:
@@ -495,7 +495,7 @@ impl CompletionsMenu {
|
||||
let last_rendered_range = self.last_rendered_range.clone();
|
||||
let style = style.clone();
|
||||
let list = uniform_list(
|
||||
cx.model().clone(),
|
||||
cx.entity().clone(),
|
||||
"completions",
|
||||
self.entries.borrow().len(),
|
||||
move |_editor, range, _window, cx| {
|
||||
@@ -1090,7 +1090,7 @@ impl CodeActionsMenu {
|
||||
let actions = self.actions.clone();
|
||||
let selected_item = self.selected_item;
|
||||
let list = uniform_list(
|
||||
cx.model().clone(),
|
||||
cx.entity().clone(),
|
||||
"code_actions_menu",
|
||||
self.actions.len(),
|
||||
move |_this, range, _, cx| {
|
||||
|
||||
@@ -1159,7 +1159,7 @@ impl Editor {
|
||||
) -> Self {
|
||||
let style = window.text_style();
|
||||
let font_size = style.font_size.to_pixels(window.rem_size());
|
||||
let editor = cx.model().downgrade();
|
||||
let editor = cx.entity().downgrade();
|
||||
let fold_placeholder = FoldPlaceholder {
|
||||
constrain_width: true,
|
||||
render: Arc::new(move |fold_id, fold_range, _, cx| {
|
||||
@@ -15339,7 +15339,7 @@ impl Render for Editor {
|
||||
};
|
||||
|
||||
EditorElement::new(
|
||||
&cx.model(),
|
||||
&cx.entity(),
|
||||
EditorStyle {
|
||||
background,
|
||||
local_player: cx.theme().players().local(),
|
||||
|
||||
@@ -62,7 +62,7 @@ fn test_edit_events(cx: &mut TestAppContext) {
|
||||
let editor1 = cx.add_window({
|
||||
let events = events.clone();
|
||||
|window, cx| {
|
||||
let model = cx.model().clone();
|
||||
let model = cx.entity().clone();
|
||||
cx.subscribe_in(
|
||||
&model,
|
||||
window,
|
||||
@@ -83,7 +83,7 @@ fn test_edit_events(cx: &mut TestAppContext) {
|
||||
let events = events.clone();
|
||||
|window, cx| {
|
||||
cx.subscribe_in(
|
||||
&cx.model().clone(),
|
||||
&cx.entity().clone(),
|
||||
window,
|
||||
move |_, _, event: &EditorEvent, _, _| match event {
|
||||
EditorEvent::Edited { .. } => events.borrow_mut().push(("editor2", "edited")),
|
||||
@@ -689,7 +689,7 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
|
||||
cx.new(|cx| {
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(300, 5, 'a'), cx);
|
||||
let mut editor = build_editor(buffer.clone(), window, cx);
|
||||
let handle = cx.model();
|
||||
let handle = cx.entity();
|
||||
editor.set_nav_history(Some(pane.read(cx).nav_history_for_item(&handle)));
|
||||
|
||||
fn pop_history(editor: &mut Editor, cx: &mut App) -> Option<NavigationEntry> {
|
||||
@@ -10180,8 +10180,8 @@ async fn test_following(cx: &mut gpui::TestAppContext) {
|
||||
let is_still_following = Rc::new(RefCell::new(true));
|
||||
let follower_edit_event_count = Rc::new(RefCell::new(0));
|
||||
let pending_update = Rc::new(RefCell::new(None));
|
||||
let leader_model = leader.root_model(cx).unwrap();
|
||||
let follower_model = follower.root_model(cx).unwrap();
|
||||
let leader_model = leader.root(cx).unwrap();
|
||||
let follower_model = follower.root(cx).unwrap();
|
||||
_ = follower.update(cx, {
|
||||
let update = pending_update.clone();
|
||||
let is_still_following = is_still_following.clone();
|
||||
@@ -10368,7 +10368,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
||||
// Start following the editor when it has no excerpts.
|
||||
let mut state_message =
|
||||
leader.update_in(cx, |leader, window, cx| leader.to_state_proto(window, cx));
|
||||
let workspace_model = workspace.root_model(cx).unwrap();
|
||||
let workspace_model = workspace.root(cx).unwrap();
|
||||
let follower_1 = cx
|
||||
.update_window(*workspace.deref(), |_, window, cx| {
|
||||
Editor::from_state_proto(
|
||||
@@ -10470,7 +10470,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
||||
// Start following separately after it already has excerpts.
|
||||
let mut state_message =
|
||||
leader.update_in(cx, |leader, window, cx| leader.to_state_proto(window, cx));
|
||||
let workspace_model = workspace.root_model(cx).unwrap();
|
||||
let workspace_model = workspace.root(cx).unwrap();
|
||||
let follower_2 = cx
|
||||
.update_window(*workspace.deref(), |_, window, cx| {
|
||||
Editor::from_state_proto(
|
||||
@@ -14497,7 +14497,7 @@ fn test_crease_insertion_and_rendering(cx: &mut TestAppContext) {
|
||||
let _div = snapshot.render_crease_toggle(
|
||||
MultiBufferRow(1),
|
||||
false,
|
||||
cx.model().clone(),
|
||||
cx.entity().clone(),
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
@@ -14718,7 +14718,7 @@ async fn test_goto_definition_with_find_all_references_fallback(cx: &mut gpui::T
|
||||
"Initially, only one, test, editor should be open in the workspace"
|
||||
);
|
||||
assert_eq!(
|
||||
test_editor_cx.model(),
|
||||
test_editor_cx.entity(),
|
||||
editors.last().expect("Asserted len is 1").clone()
|
||||
);
|
||||
});
|
||||
@@ -14754,7 +14754,7 @@ async fn test_goto_definition_with_find_all_references_fallback(cx: &mut gpui::T
|
||||
);
|
||||
let references_fallback_text = editors
|
||||
.into_iter()
|
||||
.find(|new_editor| *new_editor != test_editor_cx.model())
|
||||
.find(|new_editor| *new_editor != test_editor_cx.entity())
|
||||
.expect("Should have one non-test editor now")
|
||||
.read(test_editor_cx)
|
||||
.text(test_editor_cx);
|
||||
|
||||
@@ -6246,7 +6246,7 @@ impl Element for EditorElement {
|
||||
|
||||
let height = self.style.text.line_height_in_pixels(rem_size);
|
||||
if auto_width {
|
||||
let editor_handle = cx.model().clone();
|
||||
let editor_handle = cx.entity().clone();
|
||||
let style = self.style.clone();
|
||||
window.request_measured_layout(
|
||||
Style::default(),
|
||||
@@ -6287,7 +6287,7 @@ impl Element for EditorElement {
|
||||
}
|
||||
}
|
||||
EditorMode::AutoHeight { max_lines } => {
|
||||
let editor_handle = cx.model().clone();
|
||||
let editor_handle = cx.entity().clone();
|
||||
let max_line_number_width =
|
||||
self.max_line_number_width(&editor.snapshot(window, cx), window, cx);
|
||||
window.request_measured_layout(
|
||||
|
||||
@@ -77,7 +77,7 @@ impl ProjectDiffEditor {
|
||||
if let Some(existing) = workspace.item_of_type::<Self>(cx) {
|
||||
workspace.activate_item(&existing, true, true, window, cx);
|
||||
} else {
|
||||
let workspace_handle = cx.model().downgrade();
|
||||
let workspace_handle = cx.entity().downgrade();
|
||||
let project_diff =
|
||||
cx.new(|cx| Self::new(workspace.project().clone(), workspace_handle, window, cx));
|
||||
workspace.add_item_to_active_pane(Box::new(project_diff), None, true, window, cx);
|
||||
|
||||
@@ -596,7 +596,7 @@ impl Editor {
|
||||
style: BlockStyle::Sticky,
|
||||
priority: 0,
|
||||
render: Arc::new({
|
||||
let editor = cx.model().clone();
|
||||
let editor = cx.entity().clone();
|
||||
let hunk = hunk.clone();
|
||||
let has_multiple_hunks = self.has_multiple_hunks(cx);
|
||||
|
||||
@@ -870,7 +870,7 @@ impl Editor {
|
||||
let deleted_hunk_color = deleted_hunk_color(cx);
|
||||
let (editor_height, editor_with_deleted_text) =
|
||||
editor_with_deleted_text(diff_base_buffer, deleted_hunk_color, hunk, window, cx);
|
||||
let editor = cx.model().clone();
|
||||
let editor = cx.entity().clone();
|
||||
let hunk = hunk.clone();
|
||||
let height = editor_height.max(deleted_text_height);
|
||||
BlockProperties {
|
||||
@@ -1214,7 +1214,7 @@ fn editor_with_deleted_text(
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Editor>,
|
||||
) -> (u32, Model<Editor>) {
|
||||
let parent_editor = cx.model().downgrade();
|
||||
let parent_editor = cx.entity().downgrade();
|
||||
let editor = cx.new(|cx| {
|
||||
let multi_buffer = cx.new(|_| MultiBuffer::without_headers(language::Capability::ReadOnly));
|
||||
multi_buffer.update(cx, |multi_buffer, cx| {
|
||||
|
||||
@@ -317,7 +317,7 @@ impl ScrollManager {
|
||||
self.show_scrollbar(window, cx);
|
||||
self.autoscroll_request.take();
|
||||
if let Some(workspace_id) = workspace_id {
|
||||
let item_id = cx.model().entity_id().as_u64() as ItemId;
|
||||
let item_id = cx.entity().entity_id().as_u64() as ItemId;
|
||||
|
||||
cx.foreground_executor()
|
||||
.spawn(async move {
|
||||
|
||||
@@ -133,7 +133,7 @@ impl EditorLspTestContext {
|
||||
|
||||
let window = cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||
|
||||
let workspace = window.root_model(cx).unwrap();
|
||||
let workspace = window.root(cx).unwrap();
|
||||
|
||||
let mut cx = VisualTestContext::from_window(*window.deref(), cx);
|
||||
project
|
||||
|
||||
@@ -67,7 +67,7 @@ impl EditorTestContext {
|
||||
window.focus(&editor.focus_handle(cx));
|
||||
editor
|
||||
});
|
||||
let editor_view = editor.root_model(cx).unwrap();
|
||||
let editor_view = editor.root(cx).unwrap();
|
||||
|
||||
cx.run_until_parked();
|
||||
Self {
|
||||
@@ -89,7 +89,7 @@ impl EditorTestContext {
|
||||
}
|
||||
|
||||
pub async fn for_editor(editor: WindowHandle<Editor>, cx: &mut gpui::TestAppContext) -> Self {
|
||||
let editor_view = editor.root_model(cx).unwrap();
|
||||
let editor_view = editor.root(cx).unwrap();
|
||||
Self {
|
||||
cx: VisualTestContext::from_window(*editor.deref(), cx),
|
||||
window: editor.into(),
|
||||
@@ -126,7 +126,7 @@ impl EditorTestContext {
|
||||
editor
|
||||
});
|
||||
|
||||
let editor_view = editor.root_model(cx).unwrap();
|
||||
let editor_view = editor.root(cx).unwrap();
|
||||
Self {
|
||||
cx: VisualTestContext::from_window(*editor.deref(), cx),
|
||||
window: editor.into(),
|
||||
|
||||
Reference in New Issue
Block a user