Rename build_view
to new_view
and build_model
to new_model
(#3823)
The word "new" is shorter and blends in with `new` constructors that are common in Rust. Been meaning to do this for a while. Release Notes: - N/A
This commit is contained in:
commit
6b14f2fd08
97 changed files with 470 additions and 494 deletions
|
@ -55,7 +55,7 @@ impl ActivityIndicator {
|
|||
) -> View<ActivityIndicator> {
|
||||
let project = workspace.project().clone();
|
||||
let auto_updater = AutoUpdater::get(cx);
|
||||
let this = cx.build_view(|cx: &mut ViewContext<Self>| {
|
||||
let this = cx.new_view(|cx: &mut ViewContext<Self>| {
|
||||
let mut status_events = languages.language_server_binary_statuses();
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
while let Some((language, event)) = status_events.next().await {
|
||||
|
@ -101,9 +101,9 @@ impl ActivityIndicator {
|
|||
);
|
||||
});
|
||||
workspace.add_item(
|
||||
Box::new(cx.build_view(|cx| {
|
||||
Editor::for_buffer(buffer, Some(project.clone()), cx)
|
||||
})),
|
||||
Box::new(
|
||||
cx.new_view(|cx| Editor::for_buffer(buffer, Some(project.clone()), cx)),
|
||||
),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ impl AssistantPanel {
|
|||
// TODO: deserialize state.
|
||||
let workspace_handle = workspace.clone();
|
||||
workspace.update(&mut cx, |workspace, cx| {
|
||||
cx.build_view::<Self>(|cx| {
|
||||
cx.new_view::<Self>(|cx| {
|
||||
const CONVERSATION_WATCH_DURATION: Duration = Duration::from_millis(100);
|
||||
let _watch_saved_conversations = cx.spawn(move |this, mut cx| async move {
|
||||
let mut events = fs
|
||||
|
@ -147,10 +147,10 @@ impl AssistantPanel {
|
|||
anyhow::Ok(())
|
||||
});
|
||||
|
||||
let toolbar = cx.build_view(|cx| {
|
||||
let toolbar = cx.new_view(|cx| {
|
||||
let mut toolbar = Toolbar::new();
|
||||
toolbar.set_can_navigate(false, cx);
|
||||
toolbar.add_item(cx.build_view(|cx| BufferSearchBar::new(cx)), cx);
|
||||
toolbar.add_item(cx.new_view(|cx| BufferSearchBar::new(cx)), cx);
|
||||
toolbar
|
||||
});
|
||||
|
||||
|
@ -306,7 +306,7 @@ impl AssistantPanel {
|
|||
// Retrieve Credentials Authenticates the Provider
|
||||
provider.retrieve_credentials(cx);
|
||||
|
||||
let codegen = cx.build_model(|cx| {
|
||||
let codegen = cx.new_model(|cx| {
|
||||
Codegen::new(editor.read(cx).buffer().clone(), codegen_kind, provider, cx)
|
||||
});
|
||||
|
||||
|
@ -332,7 +332,7 @@ impl AssistantPanel {
|
|||
}
|
||||
|
||||
let measurements = Rc::new(Cell::new(BlockMeasurements::default()));
|
||||
let inline_assistant = cx.build_view(|cx| {
|
||||
let inline_assistant = cx.new_view(|cx| {
|
||||
InlineAssistant::new(
|
||||
inline_assist_id,
|
||||
measurements.clone(),
|
||||
|
@ -790,7 +790,7 @@ impl AssistantPanel {
|
|||
}
|
||||
|
||||
fn new_conversation(&mut self, cx: &mut ViewContext<Self>) -> View<ConversationEditor> {
|
||||
let editor = cx.build_view(|cx| {
|
||||
let editor = cx.new_view(|cx| {
|
||||
ConversationEditor::new(
|
||||
self.completion_provider.clone(),
|
||||
self.languages.clone(),
|
||||
|
@ -1058,7 +1058,7 @@ impl AssistantPanel {
|
|||
cx.spawn(|this, mut cx| async move {
|
||||
let saved_conversation = fs.load(&path).await?;
|
||||
let saved_conversation = serde_json::from_str(&saved_conversation)?;
|
||||
let conversation = cx.build_model(|cx| {
|
||||
let conversation = cx.new_model(|cx| {
|
||||
Conversation::deserialize(saved_conversation, path.clone(), languages, cx)
|
||||
})?;
|
||||
this.update(&mut cx, |this, cx| {
|
||||
|
@ -1067,7 +1067,7 @@ impl AssistantPanel {
|
|||
if let Some(ix) = this.editor_index_for_path(&path, cx) {
|
||||
this.set_active_editor_index(Some(ix), cx);
|
||||
} else {
|
||||
let editor = cx.build_view(|cx| {
|
||||
let editor = cx.new_view(|cx| {
|
||||
ConversationEditor::for_conversation(conversation, fs, workspace, cx)
|
||||
});
|
||||
this.add_conversation(editor, cx);
|
||||
|
@ -1093,7 +1093,7 @@ impl AssistantPanel {
|
|||
}
|
||||
|
||||
fn build_api_key_editor(cx: &mut ViewContext<AssistantPanel>) -> View<Editor> {
|
||||
cx.build_view(|cx| {
|
||||
cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text("sk-000000000000000000000000000000000000000000000000", cx);
|
||||
editor
|
||||
|
@ -1335,7 +1335,7 @@ impl Conversation {
|
|||
completion_provider: Arc<dyn CompletionProvider>,
|
||||
) -> Self {
|
||||
let markdown = language_registry.language_for_name("Markdown");
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
let mut buffer = Buffer::new(0, cx.entity_id().as_u64(), "");
|
||||
buffer.set_language_registry(language_registry);
|
||||
cx.spawn(|buffer, mut cx| async move {
|
||||
|
@ -1430,7 +1430,7 @@ impl Conversation {
|
|||
let markdown = language_registry.language_for_name("Markdown");
|
||||
let mut message_anchors = Vec::new();
|
||||
let mut next_message_id = MessageId(0);
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
let mut buffer = Buffer::new(0, cx.entity_id().as_u64(), saved_conversation.text);
|
||||
for message in saved_conversation.messages {
|
||||
message_anchors.push(MessageAnchor {
|
||||
|
@ -2081,7 +2081,7 @@ impl ConversationEditor {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
let conversation =
|
||||
cx.build_model(|cx| Conversation::new(language_registry, cx, completion_provider));
|
||||
cx.new_model(|cx| Conversation::new(language_registry, cx, completion_provider));
|
||||
Self::for_conversation(conversation, fs, workspace, cx)
|
||||
}
|
||||
|
||||
|
@ -2091,7 +2091,7 @@ impl ConversationEditor {
|
|||
workspace: WeakView<Workspace>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
let editor = cx.build_view(|cx| {
|
||||
let editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::for_buffer(conversation.read(cx).buffer.clone(), None, cx);
|
||||
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
|
||||
editor.set_show_gutter(false, cx);
|
||||
|
@ -2708,7 +2708,7 @@ impl InlineAssistant {
|
|||
semantic_index: Option<Model<SemanticIndex>>,
|
||||
project: Model<Project>,
|
||||
) -> Self {
|
||||
let prompt_editor = cx.build_view(|cx| {
|
||||
let prompt_editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
let placeholder = match codegen.read(cx).kind() {
|
||||
CodegenKind::Transform { .. } => "Enter transformation prompt…",
|
||||
|
@ -3129,8 +3129,7 @@ mod tests {
|
|||
let registry = Arc::new(LanguageRegistry::test());
|
||||
|
||||
let completion_provider = Arc::new(FakeCompletionProvider::new());
|
||||
let conversation =
|
||||
cx.build_model(|cx| Conversation::new(registry, cx, completion_provider));
|
||||
let conversation = cx.new_model(|cx| Conversation::new(registry, cx, completion_provider));
|
||||
let buffer = conversation.read(cx).buffer.clone();
|
||||
|
||||
let message_1 = conversation.read(cx).message_anchors[0].clone();
|
||||
|
@ -3261,8 +3260,7 @@ mod tests {
|
|||
let registry = Arc::new(LanguageRegistry::test());
|
||||
let completion_provider = Arc::new(FakeCompletionProvider::new());
|
||||
|
||||
let conversation =
|
||||
cx.build_model(|cx| Conversation::new(registry, cx, completion_provider));
|
||||
let conversation = cx.new_model(|cx| Conversation::new(registry, cx, completion_provider));
|
||||
let buffer = conversation.read(cx).buffer.clone();
|
||||
|
||||
let message_1 = conversation.read(cx).message_anchors[0].clone();
|
||||
|
@ -3360,8 +3358,7 @@ mod tests {
|
|||
init(cx);
|
||||
let registry = Arc::new(LanguageRegistry::test());
|
||||
let completion_provider = Arc::new(FakeCompletionProvider::new());
|
||||
let conversation =
|
||||
cx.build_model(|cx| Conversation::new(registry, cx, completion_provider));
|
||||
let conversation = cx.new_model(|cx| Conversation::new(registry, cx, completion_provider));
|
||||
let buffer = conversation.read(cx).buffer.clone();
|
||||
|
||||
let message_1 = conversation.read(cx).message_anchors[0].clone();
|
||||
|
@ -3446,7 +3443,7 @@ mod tests {
|
|||
let registry = Arc::new(LanguageRegistry::test());
|
||||
let completion_provider = Arc::new(FakeCompletionProvider::new());
|
||||
let conversation =
|
||||
cx.build_model(|cx| Conversation::new(registry.clone(), cx, completion_provider));
|
||||
cx.new_model(|cx| Conversation::new(registry.clone(), cx, completion_provider));
|
||||
let buffer = conversation.read(cx).buffer.clone();
|
||||
let message_0 = conversation.read(cx).message_anchors[0].id;
|
||||
let message_1 = conversation.update(cx, |conversation, cx| {
|
||||
|
@ -3479,7 +3476,7 @@ mod tests {
|
|||
]
|
||||
);
|
||||
|
||||
let deserialized_conversation = cx.build_model(|cx| {
|
||||
let deserialized_conversation = cx.new_model(|cx| {
|
||||
Conversation::deserialize(
|
||||
conversation.read(cx).serialize(cx),
|
||||
Default::default(),
|
||||
|
|
|
@ -395,14 +395,14 @@ mod tests {
|
|||
}
|
||||
"};
|
||||
let buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, 0, text).with_language(Arc::new(rust_lang()), cx));
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
cx.new_model(|cx| Buffer::new(0, 0, text).with_language(Arc::new(rust_lang()), cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let range = buffer.read_with(cx, |buffer, cx| {
|
||||
let snapshot = buffer.snapshot(cx);
|
||||
snapshot.anchor_before(Point::new(1, 0))..snapshot.anchor_after(Point::new(4, 5))
|
||||
});
|
||||
let provider = Arc::new(FakeCompletionProvider::new());
|
||||
let codegen = cx.build_model(|cx| {
|
||||
let codegen = cx.new_model(|cx| {
|
||||
Codegen::new(
|
||||
buffer.clone(),
|
||||
CodegenKind::Transform { range },
|
||||
|
@ -461,14 +461,14 @@ mod tests {
|
|||
}
|
||||
"};
|
||||
let buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, 0, text).with_language(Arc::new(rust_lang()), cx));
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
cx.new_model(|cx| Buffer::new(0, 0, text).with_language(Arc::new(rust_lang()), cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let position = buffer.read_with(cx, |buffer, cx| {
|
||||
let snapshot = buffer.snapshot(cx);
|
||||
snapshot.anchor_before(Point::new(1, 6))
|
||||
});
|
||||
let provider = Arc::new(FakeCompletionProvider::new());
|
||||
let codegen = cx.build_model(|cx| {
|
||||
let codegen = cx.new_model(|cx| {
|
||||
Codegen::new(
|
||||
buffer.clone(),
|
||||
CodegenKind::Generate { position },
|
||||
|
@ -526,14 +526,14 @@ mod tests {
|
|||
"}\n" //
|
||||
);
|
||||
let buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, 0, text).with_language(Arc::new(rust_lang()), cx));
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
cx.new_model(|cx| Buffer::new(0, 0, text).with_language(Arc::new(rust_lang()), cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let position = buffer.read_with(cx, |buffer, cx| {
|
||||
let snapshot = buffer.snapshot(cx);
|
||||
snapshot.anchor_before(Point::new(1, 2))
|
||||
});
|
||||
let provider = Arc::new(FakeCompletionProvider::new());
|
||||
let codegen = cx.build_model(|cx| {
|
||||
let codegen = cx.new_model(|cx| {
|
||||
Codegen::new(
|
||||
buffer.clone(),
|
||||
CodegenKind::Generate { position },
|
||||
|
|
|
@ -254,7 +254,7 @@ pub(crate) mod tests {
|
|||
}
|
||||
"};
|
||||
let buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, 0, text).with_language(Arc::new(rust_lang()), cx));
|
||||
cx.new_model(|cx| Buffer::new(0, 0, text).with_language(Arc::new(rust_lang()), cx));
|
||||
let snapshot = buffer.read(cx).snapshot();
|
||||
|
||||
assert_eq!(
|
||||
|
|
|
@ -94,7 +94,7 @@ pub fn init(http_client: Arc<dyn HttpClient>, server_url: String, cx: &mut AppCo
|
|||
.detach();
|
||||
|
||||
if let Some(version) = ZED_APP_VERSION.or_else(|| cx.app_metadata().app_version) {
|
||||
let auto_updater = cx.build_model(|cx| {
|
||||
let auto_updater = cx.new_model(|cx| {
|
||||
let updater = AutoUpdater::new(version, http_client, server_url);
|
||||
|
||||
let mut update_subscription = AutoUpdateSetting::get_global(cx)
|
||||
|
@ -160,7 +160,7 @@ pub fn notify_of_any_new_update(cx: &mut ViewContext<Workspace>) -> Option<()> {
|
|||
if should_show_notification {
|
||||
workspace.update(&mut cx, |workspace, cx| {
|
||||
workspace.show_notification(0, cx, |cx| {
|
||||
cx.build_view(|_| UpdateNotification::new(version))
|
||||
cx.new_view(|_| UpdateNotification::new(version))
|
||||
});
|
||||
updater
|
||||
.read(cx)
|
||||
|
|
|
@ -24,7 +24,7 @@ pub use room::Room;
|
|||
pub fn init(client: Arc<Client>, user_store: Model<UserStore>, cx: &mut AppContext) {
|
||||
CallSettings::register(cx);
|
||||
|
||||
let active_call = cx.build_model(|cx| ActiveCall::new(client, user_store, cx));
|
||||
let active_call = cx.new_model(|cx| ActiveCall::new(client, user_store, cx));
|
||||
cx.set_global(active_call);
|
||||
}
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ impl Room {
|
|||
cx.spawn(move |mut cx| async move {
|
||||
let response = client.request(proto::CreateRoom {}).await?;
|
||||
let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?;
|
||||
let room = cx.build_model(|cx| {
|
||||
let room = cx.new_model(|cx| {
|
||||
Self::new(
|
||||
room_proto.id,
|
||||
None,
|
||||
|
@ -343,7 +343,7 @@ impl Room {
|
|||
mut cx: AsyncAppContext,
|
||||
) -> Result<Model<Self>> {
|
||||
let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?;
|
||||
let room = cx.build_model(|cx| {
|
||||
let room = cx.new_model(|cx| {
|
||||
Self::new(
|
||||
room_proto.id,
|
||||
response.channel_id,
|
||||
|
|
|
@ -61,14 +61,14 @@ impl ChannelBuffer {
|
|||
.map(language::proto::deserialize_operation)
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
let buffer = cx.build_model(|_| {
|
||||
let buffer = cx.new_model(|_| {
|
||||
language::Buffer::remote(response.buffer_id, response.replica_id as u16, base_text)
|
||||
})?;
|
||||
buffer.update(&mut cx, |buffer, cx| buffer.apply_ops(operations, cx))??;
|
||||
|
||||
let subscription = client.subscribe_to_entity(channel.id)?;
|
||||
|
||||
anyhow::Ok(cx.build_model(|cx| {
|
||||
anyhow::Ok(cx.new_model(|cx| {
|
||||
cx.subscribe(&buffer, Self::on_buffer_update).detach();
|
||||
cx.on_release(Self::release).detach();
|
||||
let mut this = Self {
|
||||
|
|
|
@ -99,7 +99,7 @@ impl ChannelChat {
|
|||
let messages = messages_from_proto(response.messages, &user_store, &mut cx).await?;
|
||||
let loaded_all_messages = response.done;
|
||||
|
||||
Ok(cx.build_model(|cx| {
|
||||
Ok(cx.new_model(|cx| {
|
||||
cx.on_release(Self::release).detach();
|
||||
let mut this = Self {
|
||||
channel_id: channel.id,
|
||||
|
|
|
@ -20,7 +20,7 @@ use util::{async_maybe, ResultExt};
|
|||
|
||||
pub fn init(client: &Arc<Client>, user_store: Model<UserStore>, cx: &mut AppContext) {
|
||||
let channel_store =
|
||||
cx.build_model(|cx| ChannelStore::new(client.clone(), user_store.clone(), cx));
|
||||
cx.new_model(|cx| ChannelStore::new(client.clone(), user_store.clone(), cx));
|
||||
cx.set_global(channel_store);
|
||||
}
|
||||
|
||||
|
|
|
@ -345,7 +345,7 @@ async fn test_channel_messages(cx: &mut TestAppContext) {
|
|||
fn init_test(cx: &mut AppContext) -> Model<ChannelStore> {
|
||||
let http = FakeHttpClient::with_404_response();
|
||||
let client = Client::new(http.clone(), cx);
|
||||
let user_store = cx.build_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let user_store = cx.new_model(|cx| UserStore::new(client.clone(), cx));
|
||||
|
||||
let settings_store = SettingsStore::test(cx);
|
||||
cx.set_global(settings_store);
|
||||
|
|
|
@ -1579,15 +1579,15 @@ mod tests {
|
|||
async { Ok(()) }
|
||||
},
|
||||
);
|
||||
let model1 = cx.build_model(|_| TestModel {
|
||||
let model1 = cx.new_model(|_| TestModel {
|
||||
id: 1,
|
||||
subscription: None,
|
||||
});
|
||||
let model2 = cx.build_model(|_| TestModel {
|
||||
let model2 = cx.new_model(|_| TestModel {
|
||||
id: 2,
|
||||
subscription: None,
|
||||
});
|
||||
let model3 = cx.build_model(|_| TestModel {
|
||||
let model3 = cx.new_model(|_| TestModel {
|
||||
id: 3,
|
||||
subscription: None,
|
||||
});
|
||||
|
@ -1620,7 +1620,7 @@ mod tests {
|
|||
let client = cx.update(|cx| Client::new(FakeHttpClient::with_404_response(), cx));
|
||||
let server = FakeServer::for_client(user_id, &client, cx).await;
|
||||
|
||||
let model = cx.build_model(|_| TestModel::default());
|
||||
let model = cx.new_model(|_| TestModel::default());
|
||||
let (done_tx1, _done_rx1) = smol::channel::unbounded();
|
||||
let (done_tx2, mut done_rx2) = smol::channel::unbounded();
|
||||
let subscription1 = client.add_message_handler(
|
||||
|
@ -1648,7 +1648,7 @@ mod tests {
|
|||
let client = cx.update(|cx| Client::new(FakeHttpClient::with_404_response(), cx));
|
||||
let server = FakeServer::for_client(user_id, &client, cx).await;
|
||||
|
||||
let model = cx.build_model(|_| TestModel::default());
|
||||
let model = cx.new_model(|_| TestModel::default());
|
||||
let (done_tx, mut done_rx) = smol::channel::unbounded();
|
||||
let subscription = client.add_message_handler(
|
||||
model.clone().downgrade(),
|
||||
|
|
|
@ -194,7 +194,7 @@ impl FakeServer {
|
|||
client: Arc<Client>,
|
||||
cx: &mut TestAppContext,
|
||||
) -> Model<UserStore> {
|
||||
let user_store = cx.build_model(|cx| UserStore::new(client, cx));
|
||||
let user_store = cx.new_model(|cx| UserStore::new(client, cx));
|
||||
assert_eq!(
|
||||
self.receive::<proto::GetUsers>()
|
||||
.await
|
||||
|
|
|
@ -209,8 +209,8 @@ impl TestServer {
|
|||
});
|
||||
|
||||
let fs = FakeFs::new(cx.executor());
|
||||
let user_store = cx.build_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
let user_store = cx.new_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let workspace_store = cx.new_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
let mut language_registry = LanguageRegistry::test();
|
||||
language_registry.set_executor(cx.executor());
|
||||
let app_state = Arc::new(workspace::AppState {
|
||||
|
|
|
@ -105,7 +105,7 @@ impl ChannelView {
|
|||
}
|
||||
}
|
||||
|
||||
let view = cx.build_view(|cx| {
|
||||
let view = cx.new_view(|cx| {
|
||||
let mut this = Self::new(project, channel_store, channel_buffer, cx);
|
||||
this.acknowledge_buffer_version(cx);
|
||||
this
|
||||
|
@ -133,7 +133,7 @@ impl ChannelView {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
let buffer = channel_buffer.read(cx).buffer();
|
||||
let editor = cx.build_view(|cx| {
|
||||
let editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::for_buffer(buffer, None, cx);
|
||||
editor.set_collaboration_hub(Box::new(ChannelBufferCollaborationHub(
|
||||
channel_buffer.clone(),
|
||||
|
@ -274,7 +274,7 @@ impl Item for ChannelView {
|
|||
}
|
||||
|
||||
fn clone_on_split(&self, _: WorkspaceId, cx: &mut ViewContext<Self>) -> Option<View<Self>> {
|
||||
Some(cx.build_view(|cx| {
|
||||
Some(cx.new_view(|cx| {
|
||||
Self::new(
|
||||
self.project.clone(),
|
||||
self.channel_store.clone(),
|
||||
|
|
|
@ -81,18 +81,18 @@ impl ChatPanel {
|
|||
let channel_store = ChannelStore::global(cx);
|
||||
let languages = workspace.app_state().languages.clone();
|
||||
|
||||
let input_editor = cx.build_view(|cx| {
|
||||
let input_editor = cx.new_view(|cx| {
|
||||
MessageEditor::new(
|
||||
languages.clone(),
|
||||
channel_store.clone(),
|
||||
cx.build_view(|cx| Editor::auto_height(4, cx)),
|
||||
cx.new_view(|cx| Editor::auto_height(4, cx)),
|
||||
cx,
|
||||
)
|
||||
});
|
||||
|
||||
let workspace_handle = workspace.weak_handle();
|
||||
|
||||
cx.build_view(|cx: &mut ViewContext<Self>| {
|
||||
cx.new_view(|cx: &mut ViewContext<Self>| {
|
||||
let view = cx.view().downgrade();
|
||||
let message_list =
|
||||
ListState::new(0, gpui::ListAlignment::Bottom, px(1000.), move |ix, cx| {
|
||||
|
|
|
@ -219,7 +219,7 @@ mod tests {
|
|||
MessageEditor::new(
|
||||
language_registry,
|
||||
ChannelStore::global(cx),
|
||||
cx.build_view(|cx| Editor::auto_height(4, cx)),
|
||||
cx.new_view(|cx| Editor::auto_height(4, cx)),
|
||||
cx,
|
||||
)
|
||||
});
|
||||
|
@ -273,7 +273,7 @@ mod tests {
|
|||
cx.update(|cx| {
|
||||
let http = FakeHttpClient::with_404_response();
|
||||
let client = Client::new(http.clone(), cx);
|
||||
let user_store = cx.build_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let user_store = cx.new_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let settings = SettingsStore::test(cx);
|
||||
cx.set_global(settings);
|
||||
theme::init(theme::LoadThemes::JustBase, cx);
|
||||
|
|
|
@ -177,8 +177,8 @@ enum ListEntry {
|
|||
|
||||
impl CollabPanel {
|
||||
pub fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
|
||||
cx.build_view(|cx| {
|
||||
let filter_editor = cx.build_view(|cx| {
|
||||
cx.new_view(|cx| {
|
||||
let filter_editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text("Filter...", cx);
|
||||
editor
|
||||
|
@ -201,7 +201,7 @@ impl CollabPanel {
|
|||
})
|
||||
.detach();
|
||||
|
||||
let channel_name_editor = cx.build_view(|cx| Editor::single_line(cx));
|
||||
let channel_name_editor = cx.new_view(|cx| Editor::single_line(cx));
|
||||
|
||||
cx.subscribe(&channel_name_editor, |this: &mut Self, _, event, cx| {
|
||||
if let editor::EditorEvent::Blurred = event {
|
||||
|
@ -2118,7 +2118,7 @@ impl CollabPanel {
|
|||
.flex()
|
||||
.w_full()
|
||||
.on_drag(channel.clone(), move |channel, cx| {
|
||||
cx.build_view(|_| DraggedChannelView {
|
||||
cx.new_view(|_| DraggedChannelView {
|
||||
channel: channel.clone(),
|
||||
width,
|
||||
})
|
||||
|
|
|
@ -42,7 +42,7 @@ impl ChannelModal {
|
|||
) -> Self {
|
||||
cx.observe(&channel_store, |_, _, cx| cx.notify()).detach();
|
||||
let channel_modal = cx.view().downgrade();
|
||||
let picker = cx.build_view(|cx| {
|
||||
let picker = cx.new_view(|cx| {
|
||||
Picker::new(
|
||||
ChannelModalDelegate {
|
||||
channel_modal,
|
||||
|
|
|
@ -22,7 +22,7 @@ impl ContactFinder {
|
|||
potential_contacts: Arc::from([]),
|
||||
selected_index: 0,
|
||||
};
|
||||
let picker = cx.build_view(|cx| Picker::new(delegate, cx).modal(false));
|
||||
let picker = cx.new_view(|cx| Picker::new(delegate, cx).modal(false));
|
||||
|
||||
Self { picker }
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ actions!(
|
|||
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.observe_new_views(|workspace: &mut Workspace, cx| {
|
||||
let titlebar_item = cx.build_view(|cx| CollabTitlebarItem::new(workspace, cx));
|
||||
let titlebar_item = cx.new_view(|cx| CollabTitlebarItem::new(workspace, cx));
|
||||
workspace.set_titlebar_item(titlebar_item.into(), cx)
|
||||
})
|
||||
.detach();
|
||||
|
|
|
@ -87,7 +87,7 @@ impl NotificationPanel {
|
|||
let user_store = workspace.app_state().user_store.clone();
|
||||
let workspace_handle = workspace.weak_handle();
|
||||
|
||||
cx.build_view(|cx: &mut ViewContext<Self>| {
|
||||
cx.new_view(|cx: &mut ViewContext<Self>| {
|
||||
let mut status = client.status();
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
while let Some(_) = status.next().await {
|
||||
|
@ -503,7 +503,7 @@ impl NotificationPanel {
|
|||
workspace.dismiss_notification::<NotificationToast>(0, cx);
|
||||
workspace.show_notification(0, cx, |cx| {
|
||||
let workspace = cx.view().downgrade();
|
||||
cx.build_view(|_| NotificationToast {
|
||||
cx.new_view(|_| NotificationToast {
|
||||
notification_id,
|
||||
actor,
|
||||
text,
|
||||
|
|
|
@ -39,7 +39,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
|||
let options = notification_window_options(screen, window_size);
|
||||
let window = cx
|
||||
.open_window(options, |cx| {
|
||||
cx.build_view(|_| {
|
||||
cx.new_view(|_| {
|
||||
IncomingCallNotification::new(
|
||||
incoming_call.clone(),
|
||||
app_state.clone(),
|
||||
|
|
|
@ -27,7 +27,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
|||
for screen in cx.displays() {
|
||||
let options = notification_window_options(screen, window_size);
|
||||
let window = cx.open_window(options, |cx| {
|
||||
cx.build_view(|_| {
|
||||
cx.new_view(|_| {
|
||||
ProjectSharedNotification::new(
|
||||
owner.clone(),
|
||||
*project_id,
|
||||
|
|
|
@ -69,7 +69,7 @@ impl CommandPalette {
|
|||
let delegate =
|
||||
CommandPaletteDelegate::new(cx.view().downgrade(), commands, previous_focus_handle);
|
||||
|
||||
let picker = cx.build_view(|cx| Picker::new(delegate, cx));
|
||||
let picker = cx.new_view(|cx| Picker::new(delegate, cx));
|
||||
Self { picker }
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ mod tests {
|
|||
let project = Project::test(app_state.fs.clone(), [], cx).await;
|
||||
let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project.clone(), cx));
|
||||
|
||||
let editor = cx.build_view(|cx| {
|
||||
let editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_text("abc", cx);
|
||||
editor
|
||||
|
|
|
@ -51,7 +51,7 @@ pub fn init(
|
|||
node_runtime: Arc<dyn NodeRuntime>,
|
||||
cx: &mut AppContext,
|
||||
) {
|
||||
let copilot = cx.build_model({
|
||||
let copilot = cx.new_model({
|
||||
let node_runtime = node_runtime.clone();
|
||||
move |cx| Copilot::start(new_server_id, http, node_runtime, cx)
|
||||
});
|
||||
|
@ -382,7 +382,7 @@ impl Copilot {
|
|||
LanguageServer::fake("copilot".into(), Default::default(), cx.to_async());
|
||||
let http = util::http::FakeHttpClient::create(|_| async { unreachable!() });
|
||||
let node_runtime = FakeNodeRuntime::new();
|
||||
let this = cx.build_model(|cx| Self {
|
||||
let this = cx.new_model(|cx| Self {
|
||||
server_id: LanguageServerId(0),
|
||||
http: http.clone(),
|
||||
node_runtime,
|
||||
|
@ -1033,7 +1033,7 @@ mod tests {
|
|||
async fn test_buffer_management(cx: &mut TestAppContext) {
|
||||
let (copilot, mut lsp) = Copilot::fake(cx);
|
||||
|
||||
let buffer_1 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "Hello"));
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "Hello"));
|
||||
let buffer_1_uri: lsp::Url = format!("buffer://{}", buffer_1.entity_id().as_u64())
|
||||
.parse()
|
||||
.unwrap();
|
||||
|
@ -1051,7 +1051,7 @@ mod tests {
|
|||
}
|
||||
);
|
||||
|
||||
let buffer_2 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "Goodbye"));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "Goodbye"));
|
||||
let buffer_2_uri: lsp::Url = format!("buffer://{}", buffer_2.entity_id().as_u64())
|
||||
.parse()
|
||||
.unwrap();
|
||||
|
|
|
@ -71,7 +71,7 @@ fn create_copilot_auth_window(
|
|||
display_id: None,
|
||||
};
|
||||
let window = cx.open_window(window_options, |cx| {
|
||||
cx.build_view(|_| CopilotCodeVerification::new(status.clone()))
|
||||
cx.new_view(|_| CopilotCodeVerification::new(status.clone()))
|
||||
});
|
||||
window
|
||||
}
|
||||
|
|
|
@ -151,8 +151,8 @@ impl ProjectDiagnosticsEditor {
|
|||
let focus_in_subscription =
|
||||
cx.on_focus_in(&focus_handle, |diagnostics, cx| diagnostics.focus_in(cx));
|
||||
|
||||
let excerpts = cx.build_model(|cx| MultiBuffer::new(project_handle.read(cx).replica_id()));
|
||||
let editor = cx.build_view(|cx| {
|
||||
let excerpts = cx.new_model(|cx| MultiBuffer::new(project_handle.read(cx).replica_id()));
|
||||
let editor = cx.new_view(|cx| {
|
||||
let mut editor =
|
||||
Editor::for_multibuffer(excerpts.clone(), Some(project_handle.clone()), cx);
|
||||
editor.set_vertical_scroll_margin(5, cx);
|
||||
|
@ -194,7 +194,7 @@ impl ProjectDiagnosticsEditor {
|
|||
workspace.activate_item(&existing, cx);
|
||||
} else {
|
||||
let workspace_handle = cx.view().downgrade();
|
||||
let diagnostics = cx.build_view(|cx| {
|
||||
let diagnostics = cx.new_view(|cx| {
|
||||
ProjectDiagnosticsEditor::new(workspace.project().clone(), workspace_handle, cx)
|
||||
});
|
||||
workspace.add_item(Box::new(diagnostics), cx);
|
||||
|
@ -705,7 +705,7 @@ impl Item for ProjectDiagnosticsEditor {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
Some(cx.build_view(|cx| {
|
||||
Some(cx.new_view(|cx| {
|
||||
ProjectDiagnosticsEditor::new(self.project.clone(), self.workspace.clone(), cx)
|
||||
}))
|
||||
}
|
||||
|
@ -778,7 +778,7 @@ impl Item for ProjectDiagnosticsEditor {
|
|||
_item_id: workspace::ItemId,
|
||||
cx: &mut ViewContext<Pane>,
|
||||
) -> Task<Result<View<Self>>> {
|
||||
Task::ready(Ok(cx.build_view(|cx| Self::new(project, workspace, cx))))
|
||||
Task::ready(Ok(cx.new_view(|cx| Self::new(project, workspace, cx))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1046,7 +1046,7 @@ pub mod tests {
|
|||
}
|
||||
});
|
||||
|
||||
let map = cx.build_model(|cx| {
|
||||
let map = cx.new_model(|cx| {
|
||||
DisplayMap::new(
|
||||
buffer.clone(),
|
||||
font("Helvetica"),
|
||||
|
@ -1286,7 +1286,7 @@ pub mod tests {
|
|||
|
||||
let text = "one two three four five\nsix seven eight";
|
||||
let buffer = MultiBuffer::build_simple(text, cx);
|
||||
let map = cx.build_model(|cx| {
|
||||
let map = cx.new_model(|cx| {
|
||||
DisplayMap::new(
|
||||
buffer.clone(),
|
||||
font("Helvetica"),
|
||||
|
@ -1393,7 +1393,7 @@ pub mod tests {
|
|||
let buffer = MultiBuffer::build_simple(&text, cx);
|
||||
|
||||
let font_size = px(14.0);
|
||||
let map = cx.build_model(|cx| {
|
||||
let map = cx.new_model(|cx| {
|
||||
DisplayMap::new(buffer.clone(), font("Helvetica"), font_size, None, 1, 1, cx)
|
||||
});
|
||||
|
||||
|
@ -1464,17 +1464,16 @@ pub mod tests {
|
|||
|
||||
cx.update(|cx| init_test(cx, |s| s.defaults.tab_size = Some(2.try_into().unwrap())));
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
cx.condition(&buffer, |buf, _| !buf.is_parsing()).await;
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
|
||||
let font_size = px(14.0);
|
||||
|
||||
let map = cx.build_model(|cx| {
|
||||
DisplayMap::new(buffer, font("Helvetica"), font_size, None, 1, 1, cx)
|
||||
});
|
||||
let map = cx
|
||||
.new_model(|cx| DisplayMap::new(buffer, font("Helvetica"), font_size, None, 1, 1, cx));
|
||||
assert_eq!(
|
||||
cx.update(|cx| syntax_chunks(0..5, &map, &theme, cx)),
|
||||
vec![
|
||||
|
@ -1551,15 +1550,15 @@ pub mod tests {
|
|||
|
||||
cx.update(|cx| init_test(cx, |_| {}));
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
cx.condition(&buffer, |buf, _| !buf.is_parsing()).await;
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
|
||||
let font_size = px(16.0);
|
||||
|
||||
let map = cx.build_model(|cx| {
|
||||
let map = cx.new_model(|cx| {
|
||||
DisplayMap::new(buffer, font("Courier"), font_size, Some(px(40.0)), 1, 1, cx)
|
||||
});
|
||||
assert_eq!(
|
||||
|
@ -1618,17 +1617,17 @@ pub mod tests {
|
|||
|
||||
let (text, highlighted_ranges) = marked_text_ranges(r#"constˇ «a»: B = "c «d»""#, false);
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
cx.condition(&buffer, |buf, _| !buf.is_parsing()).await;
|
||||
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer_snapshot = buffer.read_with(cx, |buffer, cx| buffer.snapshot(cx));
|
||||
|
||||
let font_size = px(16.0);
|
||||
let map = cx
|
||||
.build_model(|cx| DisplayMap::new(buffer, font("Courier"), font_size, None, 1, 1, cx));
|
||||
let map =
|
||||
cx.new_model(|cx| DisplayMap::new(buffer, font("Courier"), font_size, None, 1, 1, cx));
|
||||
|
||||
enum MyType {}
|
||||
|
||||
|
@ -1742,7 +1741,7 @@ pub mod tests {
|
|||
let buffer = MultiBuffer::build_simple(text, cx);
|
||||
let font_size = px(14.0);
|
||||
|
||||
let map = cx.build_model(|cx| {
|
||||
let map = cx.new_model(|cx| {
|
||||
DisplayMap::new(buffer.clone(), font("Helvetica"), font_size, None, 1, 1, cx)
|
||||
});
|
||||
let map = map.update(cx, |map, cx| map.snapshot(cx));
|
||||
|
@ -1796,7 +1795,7 @@ pub mod tests {
|
|||
|
||||
let buffer = MultiBuffer::build_simple("aaa\n\t\tbbb", cx);
|
||||
let font_size = px(14.0);
|
||||
let map = cx.build_model(|cx| {
|
||||
let map = cx.new_model(|cx| {
|
||||
DisplayMap::new(buffer.clone(), font("Helvetica"), font_size, None, 1, 1, cx)
|
||||
});
|
||||
assert_eq!(
|
||||
|
|
|
@ -74,7 +74,7 @@ impl WrapMap {
|
|||
wrap_width: Option<Pixels>,
|
||||
cx: &mut AppContext,
|
||||
) -> (Model<Self>, WrapSnapshot) {
|
||||
let handle = cx.build_model(|cx| {
|
||||
let handle = cx.new_model(|cx| {
|
||||
let mut this = Self {
|
||||
font_with_size: (font, font_size),
|
||||
wrap_width: None,
|
||||
|
|
|
@ -1637,20 +1637,20 @@ impl InlayHintRefreshReason {
|
|||
|
||||
impl Editor {
|
||||
pub fn single_line(cx: &mut ViewContext<Self>) -> Self {
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), String::new()));
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), String::new()));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
Self::new(EditorMode::SingleLine, buffer, None, cx)
|
||||
}
|
||||
|
||||
pub fn multi_line(cx: &mut ViewContext<Self>) -> Self {
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), String::new()));
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), String::new()));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
Self::new(EditorMode::Full, buffer, None, cx)
|
||||
}
|
||||
|
||||
pub fn auto_height(max_lines: usize, cx: &mut ViewContext<Self>) -> Self {
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), String::new()));
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), String::new()));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
Self::new(EditorMode::AutoHeight { max_lines }, buffer, None, cx)
|
||||
}
|
||||
|
||||
|
@ -1659,7 +1659,7 @@ impl Editor {
|
|||
project: Option<Model<Project>>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
Self::new(EditorMode::Full, buffer, project, cx)
|
||||
}
|
||||
|
||||
|
@ -1693,13 +1693,13 @@ impl Editor {
|
|||
) -> Self {
|
||||
let style = cx.text_style();
|
||||
let font_size = style.font_size.to_pixels(cx.rem_size());
|
||||
let display_map = cx.build_model(|cx| {
|
||||
let display_map = cx.new_model(|cx| {
|
||||
DisplayMap::new(buffer.clone(), style.font(), font_size, None, 2, 1, cx)
|
||||
});
|
||||
|
||||
let selections = SelectionsCollection::new(display_map.clone(), buffer.clone());
|
||||
|
||||
let blink_manager = cx.build_model(|cx| BlinkManager::new(CURSOR_BLINK_INTERVAL, cx));
|
||||
let blink_manager = cx.new_model(|cx| BlinkManager::new(CURSOR_BLINK_INTERVAL, cx));
|
||||
|
||||
let soft_wrap_mode_override =
|
||||
(mode == EditorMode::SingleLine).then(|| language_settings::SoftWrap::None);
|
||||
|
@ -1881,7 +1881,7 @@ impl Editor {
|
|||
.log_err()
|
||||
{
|
||||
workspace.add_item(
|
||||
Box::new(cx.build_view(|cx| Editor::for_buffer(buffer, Some(project.clone()), cx))),
|
||||
Box::new(cx.new_view(|cx| Editor::for_buffer(buffer, Some(project.clone()), cx))),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
@ -1901,7 +1901,7 @@ impl Editor {
|
|||
{
|
||||
workspace.split_item(
|
||||
action.0,
|
||||
Box::new(cx.build_view(|cx| Editor::for_buffer(buffer, Some(project.clone()), cx))),
|
||||
Box::new(cx.new_view(|cx| Editor::for_buffer(buffer, Some(project.clone()), cx))),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
@ -3787,7 +3787,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
let mut ranges_to_highlight = Vec::new();
|
||||
let excerpt_buffer = cx.build_model(|cx| {
|
||||
let excerpt_buffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(replica_id).with_title(title);
|
||||
for (buffer_handle, transaction) in &entries {
|
||||
let buffer = buffer_handle.read(cx);
|
||||
|
@ -3809,7 +3809,7 @@ impl Editor {
|
|||
workspace.update(&mut cx, |workspace, cx| {
|
||||
let project = workspace.project().clone();
|
||||
let editor =
|
||||
cx.build_view(|cx| Editor::for_multibuffer(excerpt_buffer, Some(project), cx));
|
||||
cx.new_view(|cx| Editor::for_multibuffer(excerpt_buffer, Some(project), cx));
|
||||
workspace.add_item(Box::new(editor.clone()), cx);
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.highlight_background::<Self>(
|
||||
|
@ -7494,7 +7494,7 @@ impl Editor {
|
|||
let mut locations = locations.into_iter().peekable();
|
||||
let mut ranges_to_highlight = Vec::new();
|
||||
|
||||
let excerpt_buffer = cx.build_model(|cx| {
|
||||
let excerpt_buffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(replica_id);
|
||||
while let Some(location) = locations.next() {
|
||||
let buffer = location.buffer.read(cx);
|
||||
|
@ -7523,7 +7523,7 @@ impl Editor {
|
|||
multibuffer.with_title(title)
|
||||
});
|
||||
|
||||
let editor = cx.build_view(|cx| {
|
||||
let editor = cx.new_view(|cx| {
|
||||
Editor::for_multibuffer(excerpt_buffer, Some(workspace.project().clone()), cx)
|
||||
});
|
||||
editor.update(cx, |editor, cx| {
|
||||
|
@ -7608,7 +7608,7 @@ impl Editor {
|
|||
|
||||
// Position the selection in the rename editor so that it matches the current selection.
|
||||
this.show_local_selections = false;
|
||||
let rename_editor = cx.build_view(|cx| {
|
||||
let rename_editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.buffer.update(cx, |buffer, cx| {
|
||||
buffer.edit([(0..0, old_name.clone())], None, cx)
|
||||
|
|
|
@ -40,7 +40,7 @@ use workspace::{
|
|||
fn test_edit_events(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
let mut buffer = language::Buffer::new(0, cx.entity_id().as_u64(), "123456");
|
||||
buffer.set_group_interval(Duration::from_secs(1));
|
||||
buffer
|
||||
|
@ -156,9 +156,9 @@ fn test_undo_redo_with_selection_restoration(cx: &mut TestAppContext) {
|
|||
init_test(cx, |_| {});
|
||||
|
||||
let mut now = Instant::now();
|
||||
let buffer = cx.build_model(|cx| language::Buffer::new(0, cx.entity_id().as_u64(), "123456"));
|
||||
let buffer = cx.new_model(|cx| language::Buffer::new(0, cx.entity_id().as_u64(), "123456"));
|
||||
let group_interval = buffer.update(cx, |buffer, _| buffer.transaction_group_interval());
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let editor = cx.add_window(|cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
_ = editor.update(cx, |editor, cx| {
|
||||
|
@ -226,14 +226,14 @@ fn test_undo_redo_with_selection_restoration(cx: &mut TestAppContext) {
|
|||
fn test_ime_composition(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
let mut buffer = language::Buffer::new(0, cx.entity_id().as_u64(), "abcde");
|
||||
// Ensure automatic grouping doesn't occur.
|
||||
buffer.set_group_interval(Duration::ZERO);
|
||||
buffer
|
||||
});
|
||||
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
cx.add_window(|cx| {
|
||||
let mut editor = build_editor(buffer.clone(), cx);
|
||||
|
||||
|
@ -504,9 +504,7 @@ fn test_clone(cx: &mut TestAppContext) {
|
|||
|
||||
let cloned_editor = editor
|
||||
.update(cx, |editor, cx| {
|
||||
cx.open_window(Default::default(), |cx| {
|
||||
cx.build_view(|cx| editor.clone(cx))
|
||||
})
|
||||
cx.open_window(Default::default(), |cx| cx.new_view(|cx| editor.clone(cx)))
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
@ -558,7 +556,7 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
|
|||
.unwrap();
|
||||
|
||||
_ = workspace.update(cx, |_v, cx| {
|
||||
cx.build_view(|cx| {
|
||||
cx.new_view(|cx| {
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(300, 5, 'a'), cx);
|
||||
let mut editor = build_editor(buffer.clone(), cx);
|
||||
let handle = cx.view();
|
||||
|
@ -2349,14 +2347,14 @@ fn test_indent_outdent_with_excerpts(cx: &mut TestAppContext) {
|
|||
None,
|
||||
));
|
||||
|
||||
let toml_buffer = cx.build_model(|cx| {
|
||||
let toml_buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), "a = 1\nb = 2\n").with_language(toml_language, cx)
|
||||
});
|
||||
let rust_buffer = cx.build_model(|cx| {
|
||||
let rust_buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), "const c: usize = 3;\n")
|
||||
.with_language(rust_language, cx)
|
||||
});
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
multibuffer.push_excerpts(
|
||||
toml_buffer.clone(),
|
||||
|
@ -3907,10 +3905,9 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) {
|
|||
"#
|
||||
.unindent();
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx
|
||||
.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (view, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
|
||||
view.condition::<crate::EditorEvent>(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
|
@ -4073,10 +4070,9 @@ async fn test_autoindent_selections(cx: &mut gpui::TestAppContext) {
|
|||
|
||||
let text = "fn a() {}";
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx
|
||||
.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
editor
|
||||
.condition::<crate::EditorEvent>(cx, |editor, cx| !editor.buffer.read(cx).is_parsing(cx))
|
||||
|
@ -4638,10 +4634,9 @@ async fn test_surround_with_pair(cx: &mut gpui::TestAppContext) {
|
|||
"#
|
||||
.unindent();
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx
|
||||
.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (view, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
view.condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
@ -4788,10 +4783,9 @@ async fn test_delete_autoclose_pair(cx: &mut gpui::TestAppContext) {
|
|||
"#
|
||||
.unindent();
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx
|
||||
.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
editor
|
||||
.condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
|
@ -5012,7 +5006,7 @@ async fn test_document_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||
cx.executor().start_waiting();
|
||||
let fake_server = fake_servers.next().await.unwrap();
|
||||
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
_ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx));
|
||||
assert!(cx.read(|cx| editor.is_dirty(cx)));
|
||||
|
@ -5131,7 +5125,7 @@ async fn test_range_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||
cx.executor().start_waiting();
|
||||
let fake_server = fake_servers.next().await.unwrap();
|
||||
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
_ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx));
|
||||
assert!(cx.read(|cx| editor.is_dirty(cx)));
|
||||
|
@ -5258,7 +5252,7 @@ async fn test_document_format_manual_trigger(cx: &mut gpui::TestAppContext) {
|
|||
cx.executor().start_waiting();
|
||||
let fake_server = fake_servers.next().await.unwrap();
|
||||
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
_ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx));
|
||||
|
||||
|
@ -6023,9 +6017,8 @@ async fn test_toggle_block_comment(cx: &mut gpui::TestAppContext) {
|
|||
fn test_editing_disjoint_excerpts(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(3, 4, 'a')));
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(3, 4, 'a')));
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
multibuffer.push_excerpts(
|
||||
buffer.clone(),
|
||||
|
@ -6108,8 +6101,8 @@ fn test_editing_overlapping_excerpts(cx: &mut TestAppContext) {
|
|||
primary: None,
|
||||
}
|
||||
});
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), initial_text));
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), initial_text));
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
multibuffer.push_excerpts(buffer, excerpt_ranges, cx);
|
||||
multibuffer
|
||||
|
@ -6166,10 +6159,9 @@ fn test_editing_overlapping_excerpts(cx: &mut TestAppContext) {
|
|||
fn test_refresh_selections(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(3, 4, 'a')));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(3, 4, 'a')));
|
||||
let mut excerpt1_id = None;
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
excerpt1_id = multibuffer
|
||||
.push_excerpts(
|
||||
|
@ -6252,10 +6244,9 @@ fn test_refresh_selections(cx: &mut TestAppContext) {
|
|||
fn test_refresh_selections_while_selecting_with_mouse(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(3, 4, 'a')));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(3, 4, 'a')));
|
||||
let mut excerpt1_id = None;
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
excerpt1_id = multibuffer
|
||||
.push_excerpts(
|
||||
|
@ -6348,10 +6339,9 @@ async fn test_extra_newline_insertion(cx: &mut gpui::TestAppContext) {
|
|||
"{{} }\n", //
|
||||
);
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx
|
||||
.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (view, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
view.condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
@ -6479,7 +6469,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) {
|
|||
let buffer = project
|
||||
.create_buffer(&sample_text(16, 8, 'a'), None, cx)
|
||||
.unwrap();
|
||||
cx.build_model(|cx| MultiBuffer::singleton(buffer, cx))
|
||||
cx.new_model(|cx| MultiBuffer::singleton(buffer, cx))
|
||||
});
|
||||
let leader = cx.add_window(|cx| build_editor(buffer.clone(), cx));
|
||||
let follower = cx.update(|cx| {
|
||||
|
@ -6491,7 +6481,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) {
|
|||
)),
|
||||
..Default::default()
|
||||
},
|
||||
|cx| cx.build_view(|cx| build_editor(buffer.clone(), cx)),
|
||||
|cx| cx.new_view(|cx| build_editor(buffer.clone(), cx)),
|
||||
)
|
||||
});
|
||||
|
||||
|
@ -6646,8 +6636,8 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
|||
let cx = &mut VisualTestContext::from_window(*workspace.deref(), cx);
|
||||
|
||||
let leader = pane.update(cx, |_, cx| {
|
||||
let multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
cx.build_view(|cx| build_editor(multibuffer.clone(), cx))
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
cx.new_view(|cx| build_editor(multibuffer.clone(), cx))
|
||||
});
|
||||
|
||||
// Start following the editor when it has no excerpts.
|
||||
|
@ -7432,9 +7422,9 @@ async fn test_copilot_multibuffer(executor: BackgroundExecutor, cx: &mut gpui::T
|
|||
let (copilot, copilot_lsp) = Copilot::fake(cx);
|
||||
_ = cx.update(|cx| cx.set_global(copilot));
|
||||
|
||||
let buffer_1 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "a = 1\nb = 2\n"));
|
||||
let buffer_2 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "c = 3\nd = 4\n"));
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "a = 1\nb = 2\n"));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "c = 3\nd = 4\n"));
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
|
@ -7561,7 +7551,7 @@ async fn test_copilot_disabled_globs(executor: BackgroundExecutor, cx: &mut gpui
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
multibuffer.push_excerpts(
|
||||
private_buffer.clone(),
|
||||
|
@ -8091,7 +8081,7 @@ async fn test_document_format_with_prettier(cx: &mut gpui::TestAppContext) {
|
|||
.unwrap();
|
||||
|
||||
let buffer_text = "one\ntwo\nthree\n";
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
_ = editor.update(cx, |editor, cx| editor.set_text(buffer_text, cx));
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ mod tests {
|
|||
|
||||
cx.background_executor.run_until_parked();
|
||||
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
|
|
|
@ -2458,7 +2458,7 @@ pub mod tests {
|
|||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
|
@ -2798,7 +2798,7 @@ pub mod tests {
|
|||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
let (buffer_1_excerpts, buffer_2_excerpts) = multibuffer.update(cx, |multibuffer, cx| {
|
||||
let buffer_1_excerpts = multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
|
|
|
@ -96,7 +96,7 @@ impl FollowableItem for Editor {
|
|||
editor
|
||||
} else {
|
||||
pane.update(&mut cx, |_, cx| {
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer;
|
||||
if state.singleton && buffers.len() == 1 {
|
||||
multibuffer = MultiBuffer::singleton(buffers.pop().unwrap(), cx)
|
||||
|
@ -129,7 +129,7 @@ impl FollowableItem for Editor {
|
|||
multibuffer
|
||||
});
|
||||
|
||||
cx.build_view(|cx| {
|
||||
cx.new_view(|cx| {
|
||||
let mut editor =
|
||||
Editor::for_multibuffer(multibuffer, Some(project.clone()), cx);
|
||||
editor.remote_id = Some(remote_id);
|
||||
|
@ -632,7 +632,7 @@ impl Item for Editor {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
Some(cx.build_view(|cx| self.clone(cx)))
|
||||
Some(cx.new_view(|cx| self.clone(cx)))
|
||||
}
|
||||
|
||||
fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {
|
||||
|
@ -911,7 +911,7 @@ impl Item for Editor {
|
|||
.downcast::<Buffer>()
|
||||
.map_err(|_| anyhow!("Project item at stored path was not a buffer"))?;
|
||||
Ok(pane.update(&mut cx, |_, cx| {
|
||||
cx.build_view(|cx| {
|
||||
cx.new_view(|cx| {
|
||||
let mut editor = Editor::for_buffer(buffer, Some(project), cx);
|
||||
|
||||
editor.read_scroll_position_from_db(item_id, workspace_id, cx);
|
||||
|
|
|
@ -576,7 +576,7 @@ mod tests {
|
|||
let buffer = MultiBuffer::build_simple(input_text, cx);
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let display_map =
|
||||
cx.build_model(|cx| DisplayMap::new(buffer, font, font_size, None, 1, 1, cx));
|
||||
cx.new_model(|cx| DisplayMap::new(buffer, font, font_size, None, 1, 1, cx));
|
||||
|
||||
// add all kinds of inlays between two word boundaries: we should be able to cross them all, when looking for another boundary
|
||||
let mut id = 0;
|
||||
|
@ -763,9 +763,9 @@ mod tests {
|
|||
|
||||
let font = font("Helvetica");
|
||||
|
||||
let buffer = cx
|
||||
.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "abc\ndefg\nhijkl\nmn"));
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let buffer =
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "abc\ndefg\nhijkl\nmn"));
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
multibuffer.push_excerpts(
|
||||
buffer.clone(),
|
||||
|
@ -784,7 +784,7 @@ mod tests {
|
|||
multibuffer
|
||||
});
|
||||
let display_map =
|
||||
cx.build_model(|cx| DisplayMap::new(multibuffer, font, px(14.0), None, 2, 2, cx));
|
||||
cx.new_model(|cx| DisplayMap::new(multibuffer, font, px(14.0), None, 2, 2, cx));
|
||||
let snapshot = display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||
|
||||
assert_eq!(snapshot.text(), "\n\nabc\ndefg\n\n\nhijkl\nmn");
|
||||
|
|
|
@ -102,11 +102,11 @@ pub fn expand_macro_recursively(
|
|||
project.create_buffer(¯o_expansion.expansion, Some(rust_language), cx)
|
||||
})??;
|
||||
workspace.update(&mut cx, |workspace, cx| {
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
MultiBuffer::singleton(buffer, cx).with_title(macro_expansion.name)
|
||||
});
|
||||
workspace.add_item(
|
||||
Box::new(cx.build_view(|cx| Editor::for_multibuffer(buffer, Some(project), cx))),
|
||||
Box::new(cx.new_view(|cx| Editor::for_multibuffer(buffer, Some(project), cx))),
|
||||
cx,
|
||||
);
|
||||
})
|
||||
|
|
|
@ -30,7 +30,7 @@ pub fn marked_display_snapshot(
|
|||
let font_size: Pixels = 14usize.into();
|
||||
|
||||
let buffer = MultiBuffer::build_simple(&unmarked_text, cx);
|
||||
let display_map = cx.build_model(|cx| DisplayMap::new(buffer, font, font_size, None, 1, 1, cx));
|
||||
let display_map = cx.new_model(|cx| DisplayMap::new(buffer, font, font_size, None, 1, 1, cx));
|
||||
let snapshot = display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||
let markers = markers
|
||||
.into_iter()
|
||||
|
|
|
@ -154,7 +154,7 @@ impl FeedbackModal {
|
|||
buffer: Model<Buffer>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
let email_address_editor = cx.build_view(|cx| {
|
||||
let email_address_editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text("Email address (optional)", cx);
|
||||
|
||||
|
@ -169,7 +169,7 @@ impl FeedbackModal {
|
|||
let placeholder_text =
|
||||
"You can use markdown to organize your feedback with code and links.";
|
||||
|
||||
let feedback_editor = cx.build_view(|cx| {
|
||||
let feedback_editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::for_buffer(buffer, Some(project.clone()), cx);
|
||||
editor.set_placeholder_text(placeholder_text, cx);
|
||||
// editor.set_show_gutter(false, cx);
|
||||
|
|
|
@ -106,7 +106,7 @@ impl FileFinder {
|
|||
|
||||
fn new(delegate: FileFinderDelegate, cx: &mut ViewContext<Self>) -> Self {
|
||||
Self {
|
||||
picker: cx.build_view(|cx| Picker::new(delegate, cx)),
|
||||
picker: cx.new_view(|cx| Picker::new(delegate, cx)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ impl GoToLine {
|
|||
}
|
||||
|
||||
pub fn new(active_editor: View<Editor>, cx: &mut ViewContext<Self>) -> Self {
|
||||
let line_editor = cx.build_view(|cx| Editor::single_line(cx));
|
||||
let line_editor = cx.new_view(|cx| Editor::single_line(cx));
|
||||
let line_editor_change = cx.subscribe(&line_editor, Self::on_line_editor_event);
|
||||
|
||||
let editor = active_editor.read(cx);
|
||||
|
|
|
@ -1105,7 +1105,7 @@ impl Context for AppContext {
|
|||
/// Build an entity that is owned by the application. The given function will be invoked with
|
||||
/// a `ModelContext` and must return an object representing the entity. A `Model` will be returned
|
||||
/// which can be used to access the entity in a context.
|
||||
fn build_model<T: 'static>(
|
||||
fn new_model<T: 'static>(
|
||||
&mut self,
|
||||
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
||||
) -> Model<T> {
|
||||
|
|
|
@ -17,7 +17,7 @@ pub struct AsyncAppContext {
|
|||
impl Context for AsyncAppContext {
|
||||
type Result<T> = Result<T>;
|
||||
|
||||
fn build_model<T: 'static>(
|
||||
fn new_model<T: 'static>(
|
||||
&mut self,
|
||||
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
||||
) -> Self::Result<Model<T>>
|
||||
|
@ -29,7 +29,7 @@ impl Context for AsyncAppContext {
|
|||
.upgrade()
|
||||
.ok_or_else(|| anyhow!("app was released"))?;
|
||||
let mut app = app.borrow_mut();
|
||||
Ok(app.build_model(build_model))
|
||||
Ok(app.new_model(build_model))
|
||||
}
|
||||
|
||||
fn update_model<T: 'static, R>(
|
||||
|
@ -230,15 +230,14 @@ impl AsyncWindowContext {
|
|||
impl Context for AsyncWindowContext {
|
||||
type Result<T> = Result<T>;
|
||||
|
||||
fn build_model<T>(
|
||||
fn new_model<T>(
|
||||
&mut self,
|
||||
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
||||
) -> Result<Model<T>>
|
||||
where
|
||||
T: 'static,
|
||||
{
|
||||
self.window
|
||||
.update(self, |_, cx| cx.build_model(build_model))
|
||||
self.window.update(self, |_, cx| cx.new_model(build_model))
|
||||
}
|
||||
|
||||
fn update_model<T: 'static, R>(
|
||||
|
@ -281,7 +280,7 @@ impl Context for AsyncWindowContext {
|
|||
}
|
||||
|
||||
impl VisualContext for AsyncWindowContext {
|
||||
fn build_view<V>(
|
||||
fn new_view<V>(
|
||||
&mut self,
|
||||
build_view_state: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
||||
) -> Self::Result<View<V>>
|
||||
|
@ -289,7 +288,7 @@ impl VisualContext for AsyncWindowContext {
|
|||
V: 'static + Render,
|
||||
{
|
||||
self.window
|
||||
.update(self, |_, cx| cx.build_view(build_view_state))
|
||||
.update(self, |_, cx| cx.new_view(build_view_state))
|
||||
}
|
||||
|
||||
fn update_view<V: 'static, R>(
|
||||
|
|
|
@ -215,11 +215,11 @@ impl<'a, T> ModelContext<'a, T> {
|
|||
impl<'a, T> Context for ModelContext<'a, T> {
|
||||
type Result<U> = U;
|
||||
|
||||
fn build_model<U: 'static>(
|
||||
fn new_model<U: 'static>(
|
||||
&mut self,
|
||||
build_model: impl FnOnce(&mut ModelContext<'_, U>) -> U,
|
||||
) -> Model<U> {
|
||||
self.app.build_model(build_model)
|
||||
self.app.new_model(build_model)
|
||||
}
|
||||
|
||||
fn update_model<U: 'static, R>(
|
||||
|
|
|
@ -23,7 +23,7 @@ pub struct TestAppContext {
|
|||
impl Context for TestAppContext {
|
||||
type Result<T> = T;
|
||||
|
||||
fn build_model<T: 'static>(
|
||||
fn new_model<T: 'static>(
|
||||
&mut self,
|
||||
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
||||
) -> Self::Result<Model<T>>
|
||||
|
@ -31,7 +31,7 @@ impl Context for TestAppContext {
|
|||
T: 'static,
|
||||
{
|
||||
let mut app = self.app.borrow_mut();
|
||||
app.build_model(build_model)
|
||||
app.new_model(build_model)
|
||||
}
|
||||
|
||||
fn update_model<T: 'static, R>(
|
||||
|
@ -134,14 +134,12 @@ impl TestAppContext {
|
|||
V: 'static + Render,
|
||||
{
|
||||
let mut cx = self.app.borrow_mut();
|
||||
cx.open_window(WindowOptions::default(), |cx| cx.build_view(build_window))
|
||||
cx.open_window(WindowOptions::default(), |cx| cx.new_view(build_window))
|
||||
}
|
||||
|
||||
pub fn add_empty_window(&mut self) -> AnyWindowHandle {
|
||||
let mut cx = self.app.borrow_mut();
|
||||
cx.open_window(WindowOptions::default(), |cx| {
|
||||
cx.build_view(|_| EmptyView {})
|
||||
})
|
||||
cx.open_window(WindowOptions::default(), |cx| cx.new_view(|_| EmptyView {}))
|
||||
.any_handle
|
||||
}
|
||||
|
||||
|
@ -151,7 +149,7 @@ impl TestAppContext {
|
|||
V: 'static + Render,
|
||||
{
|
||||
let mut cx = self.app.borrow_mut();
|
||||
let window = cx.open_window(WindowOptions::default(), |cx| cx.build_view(build_window));
|
||||
let window = cx.open_window(WindowOptions::default(), |cx| cx.new_view(build_window));
|
||||
drop(cx);
|
||||
let view = window.root_view(self).unwrap();
|
||||
let cx = Box::new(VisualTestContext::from_window(*window.deref(), self));
|
||||
|
@ -617,11 +615,11 @@ impl<'a> VisualTestContext<'a> {
|
|||
impl<'a> Context for VisualTestContext<'a> {
|
||||
type Result<T> = <TestAppContext as Context>::Result<T>;
|
||||
|
||||
fn build_model<T: 'static>(
|
||||
fn new_model<T: 'static>(
|
||||
&mut self,
|
||||
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
||||
) -> Self::Result<Model<T>> {
|
||||
self.cx.build_model(build_model)
|
||||
self.cx.new_model(build_model)
|
||||
}
|
||||
|
||||
fn update_model<T, R>(
|
||||
|
@ -666,7 +664,7 @@ impl<'a> Context for VisualTestContext<'a> {
|
|||
}
|
||||
|
||||
impl<'a> VisualContext for VisualTestContext<'a> {
|
||||
fn build_view<V>(
|
||||
fn new_view<V>(
|
||||
&mut self,
|
||||
build_view: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
||||
) -> Self::Result<View<V>>
|
||||
|
@ -674,7 +672,7 @@ impl<'a> VisualContext for VisualTestContext<'a> {
|
|||
V: 'static + Render,
|
||||
{
|
||||
self.window
|
||||
.update(self.cx, |_, cx| cx.build_view(build_view))
|
||||
.update(self.cx, |_, cx| cx.new_view(build_view))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
|
@ -726,7 +724,7 @@ impl AnyWindowHandle {
|
|||
cx: &mut TestAppContext,
|
||||
build_view: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
||||
) -> View<V> {
|
||||
self.update(cx, |_, cx| cx.build_view(build_view)).unwrap()
|
||||
self.update(cx, |_, cx| cx.new_view(build_view)).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ use taffy::TaffyLayoutEngine;
|
|||
pub trait Context {
|
||||
type Result<T>;
|
||||
|
||||
fn build_model<T: 'static>(
|
||||
fn new_model<T: 'static>(
|
||||
&mut self,
|
||||
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
||||
) -> Self::Result<Model<T>>;
|
||||
|
@ -120,7 +120,7 @@ pub trait Context {
|
|||
}
|
||||
|
||||
pub trait VisualContext: Context {
|
||||
fn build_view<V>(
|
||||
fn new_view<V>(
|
||||
&mut self,
|
||||
build_view: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
||||
) -> Self::Result<View<V>>
|
||||
|
|
|
@ -327,7 +327,7 @@ mod test {
|
|||
fn test_on_events(cx: &mut TestAppContext) {
|
||||
let window = cx.update(|cx| {
|
||||
cx.open_window(Default::default(), |cx| {
|
||||
cx.build_view(|cx| TestView {
|
||||
cx.new_view(|cx| TestView {
|
||||
saw_key_down: false,
|
||||
saw_action: false,
|
||||
focus_handle: cx.focus_handle(),
|
||||
|
|
|
@ -1463,7 +1463,7 @@ impl<'a> WindowContext<'a> {
|
|||
if self.active_drag.is_none() {
|
||||
self.active_drag = Some(AnyDrag {
|
||||
value: Box::new(files.clone()),
|
||||
view: self.build_view(|_| files).into(),
|
||||
view: self.new_view(|_| files).into(),
|
||||
cursor_offset: position,
|
||||
});
|
||||
}
|
||||
|
@ -1842,10 +1842,7 @@ impl<'a> WindowContext<'a> {
|
|||
impl Context for WindowContext<'_> {
|
||||
type Result<T> = T;
|
||||
|
||||
fn build_model<T>(
|
||||
&mut self,
|
||||
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
||||
) -> Model<T>
|
||||
fn new_model<T>(&mut self, build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T) -> Model<T>
|
||||
where
|
||||
T: 'static,
|
||||
{
|
||||
|
@ -1916,7 +1913,7 @@ impl Context for WindowContext<'_> {
|
|||
}
|
||||
|
||||
impl VisualContext for WindowContext<'_> {
|
||||
fn build_view<V>(
|
||||
fn new_view<V>(
|
||||
&mut self,
|
||||
build_view_state: impl FnOnce(&mut ViewContext<'_, V>) -> V,
|
||||
) -> Self::Result<View<V>>
|
||||
|
@ -1962,7 +1959,7 @@ impl VisualContext for WindowContext<'_> {
|
|||
where
|
||||
V: 'static + Render,
|
||||
{
|
||||
let view = self.build_view(build_view);
|
||||
let view = self.new_view(build_view);
|
||||
self.window.root_view = Some(view.clone().into());
|
||||
self.notify();
|
||||
view
|
||||
|
@ -2728,11 +2725,11 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||
impl<V> Context for ViewContext<'_, V> {
|
||||
type Result<U> = U;
|
||||
|
||||
fn build_model<T: 'static>(
|
||||
fn new_model<T: 'static>(
|
||||
&mut self,
|
||||
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
||||
) -> Model<T> {
|
||||
self.window_cx.build_model(build_model)
|
||||
self.window_cx.new_model(build_model)
|
||||
}
|
||||
|
||||
fn update_model<T: 'static, R>(
|
||||
|
@ -2774,11 +2771,11 @@ impl<V> Context for ViewContext<'_, V> {
|
|||
}
|
||||
|
||||
impl<V: 'static> VisualContext for ViewContext<'_, V> {
|
||||
fn build_view<W: Render + 'static>(
|
||||
fn new_view<W: Render + 'static>(
|
||||
&mut self,
|
||||
build_view_state: impl FnOnce(&mut ViewContext<'_, W>) -> W,
|
||||
) -> Self::Result<View<W>> {
|
||||
self.window_cx.build_view(build_view_state)
|
||||
self.window_cx.new_view(build_view_state)
|
||||
}
|
||||
|
||||
fn update_view<V2: 'static, R>(
|
||||
|
|
|
@ -42,7 +42,7 @@ fn init_logger() {
|
|||
fn test_line_endings(cx: &mut gpui::AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let mut buffer = Buffer::new(0, cx.entity_id().as_u64(), "one\r\ntwo\rthree")
|
||||
.with_language(Arc::new(rust_lang()), cx);
|
||||
assert_eq!(buffer.text(), "one\ntwo\nthree");
|
||||
|
@ -138,8 +138,8 @@ fn test_edit_events(cx: &mut gpui::AppContext) {
|
|||
let buffer_1_events = Arc::new(Mutex::new(Vec::new()));
|
||||
let buffer_2_events = Arc::new(Mutex::new(Vec::new()));
|
||||
|
||||
let buffer1 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "abcdef"));
|
||||
let buffer2 = cx.build_model(|cx| Buffer::new(1, cx.entity_id().as_u64(), "abcdef"));
|
||||
let buffer1 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "abcdef"));
|
||||
let buffer2 = cx.new_model(|cx| Buffer::new(1, cx.entity_id().as_u64(), "abcdef"));
|
||||
let buffer1_ops = Arc::new(Mutex::new(Vec::new()));
|
||||
buffer1.update(cx, {
|
||||
let buffer1_ops = buffer1_ops.clone();
|
||||
|
@ -218,7 +218,7 @@ fn test_edit_events(cx: &mut gpui::AppContext) {
|
|||
#[gpui::test]
|
||||
async fn test_apply_diff(cx: &mut TestAppContext) {
|
||||
let text = "a\nbb\nccc\ndddd\neeeee\nffffff\n";
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
let anchor = buffer.update(cx, |buffer, _| buffer.anchor_before(Point::new(3, 3)));
|
||||
|
||||
let text = "a\nccc\ndddd\nffffff\n";
|
||||
|
@ -250,7 +250,7 @@ async fn test_normalize_whitespace(cx: &mut gpui::TestAppContext) {
|
|||
]
|
||||
.join("\n");
|
||||
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
|
||||
// Spawn a task to format the buffer's whitespace.
|
||||
// Pause so that the foratting task starts running.
|
||||
|
@ -314,7 +314,7 @@ async fn test_normalize_whitespace(cx: &mut gpui::TestAppContext) {
|
|||
#[gpui::test]
|
||||
async fn test_reparse(cx: &mut gpui::TestAppContext) {
|
||||
let text = "fn a() {}";
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(rust_lang()), cx)
|
||||
});
|
||||
|
||||
|
@ -442,7 +442,7 @@ async fn test_reparse(cx: &mut gpui::TestAppContext) {
|
|||
|
||||
#[gpui::test]
|
||||
async fn test_resetting_language(cx: &mut gpui::TestAppContext) {
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
let mut buffer =
|
||||
Buffer::new(0, cx.entity_id().as_u64(), "{}").with_language(Arc::new(rust_lang()), cx);
|
||||
buffer.set_sync_parse_timeout(Duration::ZERO);
|
||||
|
@ -492,7 +492,7 @@ async fn test_outline(cx: &mut gpui::TestAppContext) {
|
|||
"#
|
||||
.unindent();
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(rust_lang()), cx)
|
||||
});
|
||||
let outline = buffer
|
||||
|
@ -578,7 +578,7 @@ async fn test_outline_nodes_with_newlines(cx: &mut gpui::TestAppContext) {
|
|||
"#
|
||||
.unindent();
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(rust_lang()), cx)
|
||||
});
|
||||
let outline = buffer
|
||||
|
@ -616,7 +616,7 @@ async fn test_outline_with_extra_context(cx: &mut gpui::TestAppContext) {
|
|||
"#
|
||||
.unindent();
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(language), cx)
|
||||
});
|
||||
let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot());
|
||||
|
@ -660,7 +660,7 @@ async fn test_symbols_containing(cx: &mut gpui::TestAppContext) {
|
|||
"#
|
||||
.unindent();
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(rust_lang()), cx)
|
||||
});
|
||||
let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot());
|
||||
|
@ -881,7 +881,7 @@ fn test_enclosing_bracket_ranges_where_brackets_are_not_outermost_children(cx: &
|
|||
|
||||
#[gpui::test]
|
||||
fn test_range_for_syntax_ancestor(cx: &mut AppContext) {
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let text = "fn a() { b(|c| {}) }";
|
||||
let buffer =
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(rust_lang()), cx);
|
||||
|
@ -922,7 +922,7 @@ fn test_range_for_syntax_ancestor(cx: &mut AppContext) {
|
|||
fn test_autoindent_with_soft_tabs(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let text = "fn a() {}";
|
||||
let mut buffer =
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(rust_lang()), cx);
|
||||
|
@ -965,7 +965,7 @@ fn test_autoindent_with_hard_tabs(cx: &mut AppContext) {
|
|||
settings.defaults.hard_tabs = Some(true);
|
||||
});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let text = "fn a() {}";
|
||||
let mut buffer =
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(rust_lang()), cx);
|
||||
|
@ -1006,7 +1006,7 @@ fn test_autoindent_with_hard_tabs(cx: &mut AppContext) {
|
|||
fn test_autoindent_does_not_adjust_lines_with_unchanged_suggestion(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let entity_id = cx.entity_id();
|
||||
let mut buffer = Buffer::new(
|
||||
0,
|
||||
|
@ -1080,7 +1080,7 @@ fn test_autoindent_does_not_adjust_lines_with_unchanged_suggestion(cx: &mut AppC
|
|||
buffer
|
||||
});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
eprintln!("second buffer: {:?}", cx.entity_id());
|
||||
|
||||
let mut buffer = Buffer::new(
|
||||
|
@ -1147,7 +1147,7 @@ fn test_autoindent_does_not_adjust_lines_with_unchanged_suggestion(cx: &mut AppC
|
|||
fn test_autoindent_does_not_adjust_lines_within_newly_created_errors(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let mut buffer = Buffer::new(
|
||||
0,
|
||||
cx.entity_id().as_u64(),
|
||||
|
@ -1209,7 +1209,7 @@ fn test_autoindent_does_not_adjust_lines_within_newly_created_errors(cx: &mut Ap
|
|||
fn test_autoindent_adjusts_lines_when_only_text_changes(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let mut buffer = Buffer::new(
|
||||
0,
|
||||
cx.entity_id().as_u64(),
|
||||
|
@ -1266,7 +1266,7 @@ fn test_autoindent_adjusts_lines_when_only_text_changes(cx: &mut AppContext) {
|
|||
fn test_autoindent_with_edit_at_end_of_buffer(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let text = "a\nb";
|
||||
let mut buffer =
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(Arc::new(rust_lang()), cx);
|
||||
|
@ -1284,7 +1284,7 @@ fn test_autoindent_with_edit_at_end_of_buffer(cx: &mut AppContext) {
|
|||
fn test_autoindent_multi_line_insertion(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let text = "
|
||||
const a: usize = 1;
|
||||
fn b() {
|
||||
|
@ -1326,7 +1326,7 @@ fn test_autoindent_multi_line_insertion(cx: &mut AppContext) {
|
|||
fn test_autoindent_block_mode(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let text = r#"
|
||||
fn a() {
|
||||
b();
|
||||
|
@ -1410,7 +1410,7 @@ fn test_autoindent_block_mode(cx: &mut AppContext) {
|
|||
fn test_autoindent_block_mode_without_original_indent_columns(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let text = r#"
|
||||
fn a() {
|
||||
if b() {
|
||||
|
@ -1490,7 +1490,7 @@ fn test_autoindent_block_mode_without_original_indent_columns(cx: &mut AppContex
|
|||
fn test_autoindent_language_without_indents_query(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let text = "
|
||||
* one
|
||||
- a
|
||||
|
@ -1559,7 +1559,7 @@ fn test_autoindent_with_injected_languages(cx: &mut AppContext) {
|
|||
language_registry.add(html_language.clone());
|
||||
language_registry.add(javascript_language.clone());
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let (text, ranges) = marked_text_ranges(
|
||||
&"
|
||||
<div>ˇ
|
||||
|
@ -1610,7 +1610,7 @@ fn test_autoindent_query_with_outdent_captures(cx: &mut AppContext) {
|
|||
settings.defaults.tab_size = Some(2.try_into().unwrap());
|
||||
});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let mut buffer =
|
||||
Buffer::new(0, cx.entity_id().as_u64(), "").with_language(Arc::new(ruby_lang()), cx);
|
||||
|
||||
|
@ -1653,7 +1653,7 @@ fn test_autoindent_query_with_outdent_captures(cx: &mut AppContext) {
|
|||
fn test_language_scope_at_with_javascript(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let language = Language::new(
|
||||
LanguageConfig {
|
||||
name: "JavaScript".into(),
|
||||
|
@ -1786,7 +1786,7 @@ fn test_language_scope_at_with_javascript(cx: &mut AppContext) {
|
|||
fn test_language_scope_at_with_rust(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let language = Language::new(
|
||||
LanguageConfig {
|
||||
name: "Rust".into(),
|
||||
|
@ -1854,7 +1854,7 @@ fn test_language_scope_at_with_rust(cx: &mut AppContext) {
|
|||
fn test_language_scope_at_with_combined_injections(cx: &mut AppContext) {
|
||||
init_settings(cx, |_| {});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let text = r#"
|
||||
<ol>
|
||||
<% people.each do |person| %>
|
||||
|
@ -1902,7 +1902,7 @@ fn test_language_scope_at_with_combined_injections(cx: &mut AppContext) {
|
|||
fn test_serialization(cx: &mut gpui::AppContext) {
|
||||
let mut now = Instant::now();
|
||||
|
||||
let buffer1 = cx.build_model(|cx| {
|
||||
let buffer1 = cx.new_model(|cx| {
|
||||
let mut buffer = Buffer::new(0, cx.entity_id().as_u64(), "abc");
|
||||
buffer.edit([(3..3, "D")], None, cx);
|
||||
|
||||
|
@ -1925,7 +1925,7 @@ fn test_serialization(cx: &mut gpui::AppContext) {
|
|||
let ops = cx
|
||||
.background_executor()
|
||||
.block(buffer1.read(cx).serialize_ops(None, cx));
|
||||
let buffer2 = cx.build_model(|cx| {
|
||||
let buffer2 = cx.new_model(|cx| {
|
||||
let mut buffer = Buffer::from_proto(1, state, None).unwrap();
|
||||
buffer
|
||||
.apply_ops(
|
||||
|
@ -1959,10 +1959,10 @@ fn test_random_collaboration(cx: &mut AppContext, mut rng: StdRng) {
|
|||
let mut buffers = Vec::new();
|
||||
let network = Arc::new(Mutex::new(Network::new(rng.clone())));
|
||||
let base_buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), base_text.as_str()));
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), base_text.as_str()));
|
||||
|
||||
for i in 0..rng.gen_range(min_peers..=max_peers) {
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
let state = base_buffer.read(cx).to_proto();
|
||||
let ops = cx
|
||||
.background_executor()
|
||||
|
@ -2082,7 +2082,7 @@ fn test_random_collaboration(cx: &mut AppContext, mut rng: StdRng) {
|
|||
new_replica_id,
|
||||
replica_id
|
||||
);
|
||||
new_buffer = Some(cx.build_model(|cx| {
|
||||
new_buffer = Some(cx.new_model(|cx| {
|
||||
let mut new_buffer =
|
||||
Buffer::from_proto(new_replica_id, old_buffer_state, None).unwrap();
|
||||
new_buffer
|
||||
|
@ -2460,7 +2460,7 @@ fn assert_bracket_pairs(
|
|||
cx: &mut AppContext,
|
||||
) {
|
||||
let (expected_text, selection_ranges) = marked_text_ranges(selection_text, false);
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), expected_text.clone())
|
||||
.with_language(Arc::new(language), cx)
|
||||
});
|
||||
|
|
|
@ -61,7 +61,7 @@ impl LanguageSelector {
|
|||
language_registry,
|
||||
);
|
||||
|
||||
let picker = cx.build_view(|cx| Picker::new(delegate, cx));
|
||||
let picker = cx.new_view(|cx| Picker::new(delegate, cx));
|
||||
Self { picker }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ pub(crate) struct LogMenuItem {
|
|||
actions!(debug, [OpenLanguageServerLogs]);
|
||||
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
let log_store = cx.build_model(|cx| LogStore::new(cx));
|
||||
let log_store = cx.new_model(|cx| LogStore::new(cx));
|
||||
|
||||
cx.observe_new_views(move |workspace: &mut Workspace, cx| {
|
||||
let project = workspace.project();
|
||||
|
@ -93,7 +93,7 @@ pub fn init(cx: &mut AppContext) {
|
|||
let project = workspace.project().read(cx);
|
||||
if project.is_local() {
|
||||
workspace.add_item(
|
||||
Box::new(cx.build_view(|cx| {
|
||||
Box::new(cx.new_view(|cx| {
|
||||
LspLogView::new(workspace.project().clone(), log_store.clone(), cx)
|
||||
})),
|
||||
cx,
|
||||
|
@ -444,7 +444,7 @@ impl LspLogView {
|
|||
log_contents: String,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> (View<Editor>, Subscription) {
|
||||
let editor = cx.build_view(|cx| {
|
||||
let editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::multi_line(cx);
|
||||
editor.set_text(log_contents, cx);
|
||||
editor.move_to_end(&MoveToEnd, cx);
|
||||
|
|
|
@ -46,7 +46,7 @@ async fn test_lsp_logs(cx: &mut TestAppContext) {
|
|||
project.languages().add(Arc::new(rust_language));
|
||||
});
|
||||
|
||||
let log_store = cx.build_model(|cx| LogStore::new(cx));
|
||||
let log_store = cx.new_model(|cx| LogStore::new(cx));
|
||||
log_store.update(cx, |store, cx| store.add_project(&project, cx));
|
||||
|
||||
let _rust_buffer = project
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn init(cx: &mut AppContext) {
|
|||
let active_item = workspace.active_item(cx);
|
||||
let workspace_handle = workspace.weak_handle();
|
||||
let syntax_tree_view =
|
||||
cx.build_view(|cx| SyntaxTreeView::new(workspace_handle, active_item, cx));
|
||||
cx.new_view(|cx| SyntaxTreeView::new(workspace_handle, active_item, cx));
|
||||
workspace.split_item(SplitDirection::Right, Box::new(syntax_tree_view), cx)
|
||||
});
|
||||
})
|
||||
|
@ -417,7 +417,7 @@ impl Item for SyntaxTreeView {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
Some(cx.build_view(|cx| {
|
||||
Some(cx.new_view(|cx| {
|
||||
let mut clone = Self::new(self.workspace_handle.clone(), None, cx);
|
||||
if let Some(editor) = &self.editor {
|
||||
clone.set_editor(editor.editor.clone(), cx)
|
||||
|
|
|
@ -1649,17 +1649,17 @@ impl MultiBuffer {
|
|||
#[cfg(any(test, feature = "test-support"))]
|
||||
impl MultiBuffer {
|
||||
pub fn build_simple(text: &str, cx: &mut gpui::AppContext) -> Model<Self> {
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
cx.build_model(|cx| Self::singleton(buffer, cx))
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
cx.new_model(|cx| Self::singleton(buffer, cx))
|
||||
}
|
||||
|
||||
pub fn build_multi<const COUNT: usize>(
|
||||
excerpts: [(&str, Vec<Range<Point>>); COUNT],
|
||||
cx: &mut gpui::AppContext,
|
||||
) -> Model<Self> {
|
||||
let multi = cx.build_model(|_| Self::new(0));
|
||||
let multi = cx.new_model(|_| Self::new(0));
|
||||
for (text, ranges) in excerpts {
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
let excerpt_ranges = ranges.into_iter().map(|range| ExcerptRange {
|
||||
context: range,
|
||||
primary: None,
|
||||
|
@ -1673,11 +1673,11 @@ impl MultiBuffer {
|
|||
}
|
||||
|
||||
pub fn build_from_buffer(buffer: Model<Buffer>, cx: &mut gpui::AppContext) -> Model<Self> {
|
||||
cx.build_model(|cx| Self::singleton(buffer, cx))
|
||||
cx.new_model(|cx| Self::singleton(buffer, cx))
|
||||
}
|
||||
|
||||
pub fn build_random(rng: &mut impl rand::Rng, cx: &mut gpui::AppContext) -> Model<Self> {
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
let mutation_count = rng.gen_range(1..=5);
|
||||
multibuffer.randomly_edit_excerpts(rng, mutation_count, cx);
|
||||
|
@ -1748,8 +1748,7 @@ impl MultiBuffer {
|
|||
if excerpt_ids.is_empty() || (rng.gen() && excerpt_ids.len() < max_excerpts) {
|
||||
let buffer_handle = if rng.gen() || self.buffers.borrow().is_empty() {
|
||||
let text = RandomCharIter::new(&mut *rng).take(10).collect::<String>();
|
||||
buffers
|
||||
.push(cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text)));
|
||||
buffers.push(cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text)));
|
||||
let buffer = buffers.last().unwrap().read(cx);
|
||||
log::info!(
|
||||
"Creating new buffer {} with text: {:?}",
|
||||
|
@ -4144,8 +4143,8 @@ mod tests {
|
|||
#[gpui::test]
|
||||
fn test_singleton(cx: &mut AppContext) {
|
||||
let buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(6, 6, 'a')));
|
||||
let multibuffer = cx.build_model(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(6, 6, 'a')));
|
||||
let multibuffer = cx.new_model(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
||||
|
||||
let snapshot = multibuffer.read(cx).snapshot(cx);
|
||||
assert_eq!(snapshot.text(), buffer.read(cx).text());
|
||||
|
@ -4171,8 +4170,8 @@ mod tests {
|
|||
|
||||
#[gpui::test]
|
||||
fn test_remote(cx: &mut AppContext) {
|
||||
let host_buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "a"));
|
||||
let guest_buffer = cx.build_model(|cx| {
|
||||
let host_buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "a"));
|
||||
let guest_buffer = cx.new_model(|cx| {
|
||||
let state = host_buffer.read(cx).to_proto();
|
||||
let ops = cx
|
||||
.background_executor()
|
||||
|
@ -4187,7 +4186,7 @@ mod tests {
|
|||
.unwrap();
|
||||
buffer
|
||||
});
|
||||
let multibuffer = cx.build_model(|cx| MultiBuffer::singleton(guest_buffer.clone(), cx));
|
||||
let multibuffer = cx.new_model(|cx| MultiBuffer::singleton(guest_buffer.clone(), cx));
|
||||
let snapshot = multibuffer.read(cx).snapshot(cx);
|
||||
assert_eq!(snapshot.text(), "a");
|
||||
|
||||
|
@ -4203,10 +4202,10 @@ mod tests {
|
|||
#[gpui::test]
|
||||
fn test_excerpt_boundaries_and_clipping(cx: &mut AppContext) {
|
||||
let buffer_1 =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(6, 6, 'a')));
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(6, 6, 'a')));
|
||||
let buffer_2 =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(6, 6, 'g')));
|
||||
let multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(6, 6, 'g')));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
|
||||
let events = Arc::new(RwLock::new(Vec::<Event>::new()));
|
||||
multibuffer.update(cx, |_, cx| {
|
||||
|
@ -4439,12 +4438,12 @@ mod tests {
|
|||
#[gpui::test]
|
||||
fn test_excerpt_events(cx: &mut AppContext) {
|
||||
let buffer_1 =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(10, 3, 'a')));
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(10, 3, 'a')));
|
||||
let buffer_2 =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(10, 3, 'm')));
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(10, 3, 'm')));
|
||||
|
||||
let leader_multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
let follower_multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
let leader_multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
let follower_multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
let follower_edit_event_count = Arc::new(RwLock::new(0));
|
||||
|
||||
follower_multibuffer.update(cx, |_, cx| {
|
||||
|
@ -4547,8 +4546,8 @@ mod tests {
|
|||
#[gpui::test]
|
||||
fn test_push_excerpts_with_context_lines(cx: &mut AppContext) {
|
||||
let buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(20, 3, 'a')));
|
||||
let multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(20, 3, 'a')));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
let anchor_ranges = multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts_with_context_lines(
|
||||
buffer.clone(),
|
||||
|
@ -4584,8 +4583,8 @@ mod tests {
|
|||
#[gpui::test]
|
||||
async fn test_stream_excerpts_with_context_lines(cx: &mut TestAppContext) {
|
||||
let buffer =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(20, 3, 'a')));
|
||||
let multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), sample_text(20, 3, 'a')));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
let anchor_ranges = multibuffer.update(cx, |multibuffer, cx| {
|
||||
let snapshot = buffer.read(cx);
|
||||
let ranges = vec![
|
||||
|
@ -4620,7 +4619,7 @@ mod tests {
|
|||
|
||||
#[gpui::test]
|
||||
fn test_empty_multibuffer(cx: &mut AppContext) {
|
||||
let multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
|
||||
let snapshot = multibuffer.read(cx).snapshot(cx);
|
||||
assert_eq!(snapshot.text(), "");
|
||||
|
@ -4630,8 +4629,8 @@ mod tests {
|
|||
|
||||
#[gpui::test]
|
||||
fn test_singleton_multibuffer_anchors(cx: &mut AppContext) {
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "abcd"));
|
||||
let multibuffer = cx.build_model(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "abcd"));
|
||||
let multibuffer = cx.new_model(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
||||
let old_snapshot = multibuffer.read(cx).snapshot(cx);
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
buffer.edit([(0..0, "X")], None, cx);
|
||||
|
@ -4650,9 +4649,9 @@ mod tests {
|
|||
|
||||
#[gpui::test]
|
||||
fn test_multibuffer_anchors(cx: &mut AppContext) {
|
||||
let buffer_1 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "abcd"));
|
||||
let buffer_2 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "efghi"));
|
||||
let multibuffer = cx.build_model(|cx| {
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "abcd"));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "efghi"));
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
|
@ -4708,10 +4707,10 @@ mod tests {
|
|||
|
||||
#[gpui::test]
|
||||
fn test_resolving_anchors_after_replacing_their_excerpts(cx: &mut AppContext) {
|
||||
let buffer_1 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "abcd"));
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "abcd"));
|
||||
let buffer_2 =
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "ABCDEFGHIJKLMNOP"));
|
||||
let multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "ABCDEFGHIJKLMNOP"));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
|
||||
// Create an insertion id in buffer 1 that doesn't exist in buffer 2.
|
||||
// Add an excerpt from buffer 1 that spans this new insertion.
|
||||
|
@ -4845,7 +4844,7 @@ mod tests {
|
|||
.unwrap_or(10);
|
||||
|
||||
let mut buffers: Vec<Model<Buffer>> = Vec::new();
|
||||
let multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
let mut excerpt_ids = Vec::<ExcerptId>::new();
|
||||
let mut expected_excerpts = Vec::<(Model<Buffer>, Range<text::Anchor>)>::new();
|
||||
let mut anchors = Vec::new();
|
||||
|
@ -4922,7 +4921,7 @@ mod tests {
|
|||
.take(10)
|
||||
.collect::<String>();
|
||||
buffers.push(
|
||||
cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), base_text)),
|
||||
cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), base_text)),
|
||||
);
|
||||
buffers.last().unwrap()
|
||||
} else {
|
||||
|
@ -5265,9 +5264,9 @@ mod tests {
|
|||
let test_settings = SettingsStore::test(cx);
|
||||
cx.set_global(test_settings);
|
||||
|
||||
let buffer_1 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "1234"));
|
||||
let buffer_2 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "5678"));
|
||||
let multibuffer = cx.build_model(|_| MultiBuffer::new(0));
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "1234"));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "5678"));
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(0));
|
||||
let group_interval = multibuffer.read(cx).history.group_interval;
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts(
|
||||
|
|
|
@ -11,7 +11,7 @@ use time::OffsetDateTime;
|
|||
use util::ResultExt;
|
||||
|
||||
pub fn init(client: Arc<Client>, user_store: Model<UserStore>, cx: &mut AppContext) {
|
||||
let notification_store = cx.build_model(|cx| NotificationStore::new(client, user_store, cx));
|
||||
let notification_store = cx.new_model(|cx| NotificationStore::new(client, user_store, cx));
|
||||
cx.set_global(notification_store);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ impl OutlineView {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) -> OutlineView {
|
||||
let delegate = OutlineViewDelegate::new(cx.view().downgrade(), outline, editor, cx);
|
||||
let picker = cx.build_view(|cx| Picker::new(delegate, cx));
|
||||
let picker = cx.new_view(|cx| Picker::new(delegate, cx));
|
||||
OutlineView { picker }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ impl<D: PickerDelegate> FocusableView for Picker<D> {
|
|||
|
||||
impl<D: PickerDelegate> Picker<D> {
|
||||
pub fn new(delegate: D, cx: &mut ViewContext<Self>) -> Self {
|
||||
let editor = cx.build_view(|cx| {
|
||||
let editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text(delegate.placeholder_text(), cx);
|
||||
editor
|
||||
|
|
|
@ -636,7 +636,7 @@ impl Project {
|
|||
fs: Arc<dyn Fs>,
|
||||
cx: &mut AppContext,
|
||||
) -> Model<Self> {
|
||||
cx.build_model(|cx: &mut ModelContext<Self>| {
|
||||
cx.new_model(|cx: &mut ModelContext<Self>| {
|
||||
let (tx, rx) = mpsc::unbounded();
|
||||
cx.spawn(move |this, cx| Self::send_buffer_ordered_messages(this, rx, cx))
|
||||
.detach();
|
||||
|
@ -712,7 +712,7 @@ impl Project {
|
|||
project_id: remote_id,
|
||||
})
|
||||
.await?;
|
||||
let this = cx.build_model(|cx| {
|
||||
let this = cx.new_model(|cx| {
|
||||
let replica_id = response.payload.replica_id as ReplicaId;
|
||||
|
||||
let mut worktrees = Vec::new();
|
||||
|
@ -868,7 +868,7 @@ impl Project {
|
|||
languages.set_executor(cx.executor());
|
||||
let http_client = util::http::FakeHttpClient::with_404_response();
|
||||
let client = cx.update(|cx| client::Client::new(http_client.clone(), cx));
|
||||
let user_store = cx.build_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let user_store = cx.new_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let project = cx.update(|cx| {
|
||||
Project::local(
|
||||
client,
|
||||
|
@ -1690,7 +1690,7 @@ impl Project {
|
|||
return Err(anyhow!("creating buffers as a guest is not supported yet"));
|
||||
}
|
||||
let id = post_inc(&mut self.next_buffer_id);
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(self.replica_id(), id, text)
|
||||
.with_language(language.unwrap_or_else(|| language::PLAIN_TEXT.clone()), cx)
|
||||
});
|
||||
|
@ -7193,7 +7193,7 @@ impl Project {
|
|||
}
|
||||
|
||||
let buffer_id = state.id;
|
||||
let buffer = cx.build_model(|_| {
|
||||
let buffer = cx.new_model(|_| {
|
||||
Buffer::from_proto(this.replica_id(), state, buffer_file).unwrap()
|
||||
});
|
||||
this.incomplete_remote_buffers
|
||||
|
|
|
@ -39,7 +39,7 @@ impl Project {
|
|||
window,
|
||||
)
|
||||
.map(|builder| {
|
||||
let terminal_handle = cx.build_model(|cx| builder.subscribe(cx));
|
||||
let terminal_handle = cx.new_model(|cx| builder.subscribe(cx));
|
||||
|
||||
self.terminals
|
||||
.local_handles
|
||||
|
|
|
@ -312,7 +312,7 @@ impl Worktree {
|
|||
let closure_fs = Arc::clone(&fs);
|
||||
let closure_next_entry_id = Arc::clone(&next_entry_id);
|
||||
let closure_abs_path = abs_path.to_path_buf();
|
||||
cx.build_model(move |cx: &mut ModelContext<Worktree>| {
|
||||
cx.new_model(move |cx: &mut ModelContext<Worktree>| {
|
||||
cx.observe_global::<SettingsStore>(move |this, cx| {
|
||||
if let Self::Local(this) = this {
|
||||
let new_file_scan_exclusions =
|
||||
|
@ -415,7 +415,7 @@ impl Worktree {
|
|||
client: Arc<Client>,
|
||||
cx: &mut AppContext,
|
||||
) -> Model<Self> {
|
||||
cx.build_model(|cx: &mut ModelContext<Self>| {
|
||||
cx.new_model(|cx: &mut ModelContext<Self>| {
|
||||
let snapshot = Snapshot {
|
||||
id: WorktreeId(worktree.id as usize),
|
||||
abs_path: Arc::from(PathBuf::from(worktree.abs_path)),
|
||||
|
@ -682,7 +682,7 @@ impl LocalWorktree {
|
|||
.background_executor()
|
||||
.spawn(async move { text::Buffer::new(0, id, contents) })
|
||||
.await;
|
||||
cx.build_model(|_| Buffer::build(text_buffer, diff_base, Some(Arc::new(file))))
|
||||
cx.new_model(|_| Buffer::build(text_buffer, diff_base, Some(Arc::new(file))))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ struct DraggedProjectEntryView {
|
|||
impl ProjectPanel {
|
||||
fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
|
||||
let project = workspace.project().clone();
|
||||
let project_panel = cx.build_view(|cx: &mut ViewContext<Self>| {
|
||||
let project_panel = cx.new_view(|cx: &mut ViewContext<Self>| {
|
||||
cx.observe(&project, |this, _, cx| {
|
||||
this.update_visible_entries(None, cx);
|
||||
cx.notify();
|
||||
|
@ -200,7 +200,7 @@ impl ProjectPanel {
|
|||
})
|
||||
.detach();
|
||||
|
||||
let filename_editor = cx.build_view(|cx| Editor::single_line(cx));
|
||||
let filename_editor = cx.new_view(|cx| Editor::single_line(cx));
|
||||
|
||||
cx.subscribe(&filename_editor, |this, _, event, cx| match event {
|
||||
editor::EditorEvent::BufferEdited
|
||||
|
@ -1384,7 +1384,7 @@ impl ProjectPanel {
|
|||
div()
|
||||
.id(entry_id.to_proto() as usize)
|
||||
.on_drag(entry_id, move |entry_id, cx| {
|
||||
cx.build_view(|_| DraggedProjectEntryView {
|
||||
cx.new_view(|_| DraggedProjectEntryView {
|
||||
details: details.clone(),
|
||||
width,
|
||||
entry_id: *entry_id,
|
||||
|
|
|
@ -340,7 +340,7 @@ mod tests {
|
|||
let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project.clone(), cx));
|
||||
|
||||
// Create the project symbols view.
|
||||
let symbols = cx.build_view(|cx| {
|
||||
let symbols = cx.new_view(|cx| {
|
||||
Picker::new(
|
||||
ProjectSymbolsDelegate::new(workspace.downgrade(), project.clone()),
|
||||
cx,
|
||||
|
|
|
@ -30,7 +30,7 @@ impl ModalView for RecentProjects {}
|
|||
|
||||
impl RecentProjects {
|
||||
fn new(delegate: RecentProjectsDelegate, rem_width: f32, cx: &mut ViewContext<Self>) -> Self {
|
||||
let picker = cx.build_view(|cx| Picker::new(delegate, cx));
|
||||
let picker = cx.new_view(|cx| Picker::new(delegate, cx));
|
||||
let _subscription = cx.subscribe(&picker, |_, _, _, cx| cx.emit(DismissEvent));
|
||||
// We do not want to block the UI on a potentially lenghty call to DB, so we're gonna swap
|
||||
// out workspace locations once the future runs to completion.
|
||||
|
@ -90,7 +90,7 @@ impl RecentProjects {
|
|||
}))
|
||||
}
|
||||
pub fn open_popover(workspace: WeakView<Workspace>, cx: &mut WindowContext<'_>) -> View<Self> {
|
||||
cx.build_view(|cx| Self::new(RecentProjectsDelegate::new(workspace, false), 20., cx))
|
||||
cx.new_view(|cx| Self::new(RecentProjectsDelegate::new(workspace, false), 20., cx))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -434,7 +434,7 @@ impl BufferSearchBar {
|
|||
});
|
||||
return;
|
||||
}
|
||||
let view = cx.build_view(|cx| BufferSearchBar::new(cx));
|
||||
let view = cx.new_view(|cx| BufferSearchBar::new(cx));
|
||||
this.add_item(view.clone(), cx);
|
||||
view.update(cx, |this, cx| this.deploy(deploy, cx));
|
||||
cx.notify();
|
||||
|
@ -506,10 +506,10 @@ impl BufferSearchBar {
|
|||
});
|
||||
}
|
||||
pub fn new(cx: &mut ViewContext<Self>) -> Self {
|
||||
let query_editor = cx.build_view(|cx| Editor::single_line(cx));
|
||||
let query_editor = cx.new_view(|cx| Editor::single_line(cx));
|
||||
cx.subscribe(&query_editor, Self::on_query_editor_event)
|
||||
.detach();
|
||||
let replacement_editor = cx.build_view(|cx| Editor::single_line(cx));
|
||||
let replacement_editor = cx.new_view(|cx| Editor::single_line(cx));
|
||||
cx.subscribe(&replacement_editor, Self::on_query_editor_event)
|
||||
.detach();
|
||||
Self {
|
||||
|
@ -1044,7 +1044,7 @@ mod tests {
|
|||
&mut VisualTestContext<'_>,
|
||||
) {
|
||||
init_globals(cx);
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::new(
|
||||
0,
|
||||
cx.entity_id().as_u64(),
|
||||
|
@ -1058,9 +1058,9 @@ mod tests {
|
|||
)
|
||||
});
|
||||
let (_, cx) = cx.add_window_view(|_| EmptyView {});
|
||||
let editor = cx.build_view(|cx| Editor::for_buffer(buffer.clone(), None, cx));
|
||||
let editor = cx.new_view(|cx| Editor::for_buffer(buffer.clone(), None, cx));
|
||||
|
||||
let search_bar = cx.build_view(|cx| {
|
||||
let search_bar = cx.new_view(|cx| {
|
||||
let mut search_bar = BufferSearchBar::new(cx);
|
||||
search_bar.set_active_pane_item(Some(&editor), cx);
|
||||
search_bar.show(cx);
|
||||
|
@ -1405,7 +1405,7 @@ mod tests {
|
|||
expected_query_matches_count > 1,
|
||||
"Should pick a query with multiple results"
|
||||
);
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), buffer_text));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), buffer_text));
|
||||
let window = cx.add_window(|_| EmptyView {});
|
||||
|
||||
let editor = window.build_view(cx, |cx| Editor::for_buffer(buffer.clone(), None, cx));
|
||||
|
@ -1602,12 +1602,12 @@ mod tests {
|
|||
for "find" or "find and replace" operations on strings, or for input validation.
|
||||
"#
|
||||
.unindent();
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), buffer_text));
|
||||
let buffer = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), buffer_text));
|
||||
let (_, cx) = cx.add_window_view(|_| EmptyView {});
|
||||
|
||||
let editor = cx.build_view(|cx| Editor::for_buffer(buffer.clone(), None, cx));
|
||||
let editor = cx.new_view(|cx| Editor::for_buffer(buffer.clone(), None, cx));
|
||||
|
||||
let search_bar = cx.build_view(|cx| {
|
||||
let search_bar = cx.new_view(|cx| {
|
||||
let mut search_bar = BufferSearchBar::new(cx);
|
||||
search_bar.set_active_pane_item(Some(&editor), cx);
|
||||
search_bar.show(cx);
|
||||
|
|
|
@ -134,7 +134,7 @@ impl ProjectSearch {
|
|||
let replica_id = project.read(cx).replica_id();
|
||||
Self {
|
||||
project,
|
||||
excerpts: cx.build_model(|_| MultiBuffer::new(replica_id)),
|
||||
excerpts: cx.new_model(|_| MultiBuffer::new(replica_id)),
|
||||
pending_search: Default::default(),
|
||||
match_ranges: Default::default(),
|
||||
active_query: None,
|
||||
|
@ -145,11 +145,11 @@ impl ProjectSearch {
|
|||
}
|
||||
|
||||
fn clone(&self, cx: &mut ModelContext<Self>) -> Model<Self> {
|
||||
cx.build_model(|cx| Self {
|
||||
cx.new_model(|cx| Self {
|
||||
project: self.project.clone(),
|
||||
excerpts: self
|
||||
.excerpts
|
||||
.update(cx, |excerpts, cx| cx.build_model(|cx| excerpts.clone(cx))),
|
||||
.update(cx, |excerpts, cx| cx.new_model(|cx| excerpts.clone(cx))),
|
||||
pending_search: Default::default(),
|
||||
match_ranges: self.match_ranges.clone(),
|
||||
active_query: self.active_query.clone(),
|
||||
|
@ -504,7 +504,7 @@ impl Item for ProjectSearchView {
|
|||
Self: Sized,
|
||||
{
|
||||
let model = self.model.update(cx, |model, cx| model.clone(cx));
|
||||
Some(cx.build_view(|cx| Self::new(model, cx, None)))
|
||||
Some(cx.new_view(|cx| Self::new(model, cx, None)))
|
||||
}
|
||||
|
||||
fn added_to_workspace(&mut self, workspace: &mut Workspace, cx: &mut ViewContext<Self>) {
|
||||
|
@ -805,7 +805,7 @@ impl ProjectSearchView {
|
|||
}
|
||||
subscriptions.push(cx.observe(&model, |this, _, cx| this.model_changed(cx)));
|
||||
|
||||
let query_editor = cx.build_view(|cx| {
|
||||
let query_editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text("Text search all files", cx);
|
||||
editor.set_text(query_text, cx);
|
||||
|
@ -817,7 +817,7 @@ impl ProjectSearchView {
|
|||
cx.emit(ViewEvent::EditorEvent(event.clone()))
|
||||
}),
|
||||
);
|
||||
let replacement_editor = cx.build_view(|cx| {
|
||||
let replacement_editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text("Replace in project..", cx);
|
||||
if let Some(text) = replacement_text {
|
||||
|
@ -825,7 +825,7 @@ impl ProjectSearchView {
|
|||
}
|
||||
editor
|
||||
});
|
||||
let results_editor = cx.build_view(|cx| {
|
||||
let results_editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::for_multibuffer(excerpts, Some(project.clone()), cx);
|
||||
editor.set_searchable(false);
|
||||
editor
|
||||
|
@ -842,7 +842,7 @@ impl ProjectSearchView {
|
|||
}),
|
||||
);
|
||||
|
||||
let included_files_editor = cx.build_view(|cx| {
|
||||
let included_files_editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text("Include: crates/**/*.toml", cx);
|
||||
|
||||
|
@ -855,7 +855,7 @@ impl ProjectSearchView {
|
|||
}),
|
||||
);
|
||||
|
||||
let excluded_files_editor = cx.build_view(|cx| {
|
||||
let excluded_files_editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text("Exclude: vendor/*, *.lock", cx);
|
||||
|
||||
|
@ -929,8 +929,8 @@ impl ProjectSearchView {
|
|||
return;
|
||||
};
|
||||
|
||||
let model = cx.build_model(|cx| ProjectSearch::new(workspace.project().clone(), cx));
|
||||
let search = cx.build_view(|cx| ProjectSearchView::new(model, cx, None));
|
||||
let model = cx.new_model(|cx| ProjectSearch::new(workspace.project().clone(), cx));
|
||||
let search = cx.new_view(|cx| ProjectSearchView::new(model, cx, None));
|
||||
workspace.add_item(Box::new(search.clone()), cx);
|
||||
search.update(cx, |search, cx| {
|
||||
search
|
||||
|
@ -973,8 +973,8 @@ impl ProjectSearchView {
|
|||
None
|
||||
};
|
||||
|
||||
let model = cx.build_model(|cx| ProjectSearch::new(workspace.project().clone(), cx));
|
||||
let search = cx.build_view(|cx| ProjectSearchView::new(model, cx, settings));
|
||||
let model = cx.new_model(|cx| ProjectSearch::new(workspace.project().clone(), cx));
|
||||
let search = cx.new_view(|cx| ProjectSearchView::new(model, cx, settings));
|
||||
|
||||
workspace.add_item(Box::new(search.clone()), cx);
|
||||
|
||||
|
@ -1293,13 +1293,13 @@ impl ProjectSearchBar {
|
|||
new_query
|
||||
});
|
||||
if let Some(new_query) = new_query {
|
||||
let model = cx.build_model(|cx| {
|
||||
let model = cx.new_model(|cx| {
|
||||
let mut model = ProjectSearch::new(workspace.project().clone(), cx);
|
||||
model.search(new_query, cx);
|
||||
model
|
||||
});
|
||||
workspace.add_item(
|
||||
Box::new(cx.build_view(|cx| ProjectSearchView::new(model, cx, None))),
|
||||
Box::new(cx.new_view(|cx| ProjectSearchView::new(model, cx, None))),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
@ -1944,7 +1944,7 @@ pub mod tests {
|
|||
)
|
||||
.await;
|
||||
let project = Project::test(fs.clone(), ["/dir".as_ref()], cx).await;
|
||||
let search = cx.build_model(|cx| ProjectSearch::new(project, cx));
|
||||
let search = cx.new_model(|cx| ProjectSearch::new(project, cx));
|
||||
let search_view = cx.add_window(|cx| ProjectSearchView::new(search.clone(), cx, None));
|
||||
|
||||
search_view
|
||||
|
|
|
@ -341,7 +341,7 @@ impl SemanticIndex {
|
|||
t0.elapsed().as_millis()
|
||||
);
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let t0 = Instant::now();
|
||||
let embedding_queue =
|
||||
EmbeddingQueue::new(embedding_provider.clone(), cx.background_executor().clone());
|
||||
|
|
|
@ -11,8 +11,8 @@ pub struct AutoHeightEditorStory {
|
|||
impl AutoHeightEditorStory {
|
||||
pub fn new(cx: &mut WindowContext) -> View<Self> {
|
||||
cx.bind_keys([KeyBinding::new("enter", editor::Newline, Some("Editor"))]);
|
||||
cx.build_view(|cx| Self {
|
||||
editor: cx.build_view(|cx| {
|
||||
cx.new_view(|cx| Self {
|
||||
editor: cx.new_view(|cx| {
|
||||
let mut editor = Editor::auto_height(3, cx);
|
||||
editor.set_soft_wrap_mode(language::language_settings::SoftWrap::EditorWidth, cx);
|
||||
editor
|
||||
|
|
|
@ -20,7 +20,7 @@ impl FocusStory {
|
|||
KeyBinding::new("cmd-c", ActionC, None),
|
||||
]);
|
||||
|
||||
cx.build_view(move |cx| {
|
||||
cx.new_view(move |cx| {
|
||||
let parent_focus = cx.focus_handle();
|
||||
let child_1_focus = cx.focus_handle();
|
||||
let child_2_focus = cx.focus_handle();
|
||||
|
|
|
@ -9,7 +9,7 @@ pub struct KitchenSinkStory;
|
|||
|
||||
impl KitchenSinkStory {
|
||||
pub fn view(cx: &mut WindowContext) -> View<Self> {
|
||||
cx.build_view(|_cx| Self)
|
||||
cx.new_view(|_cx| Self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ impl PickerDelegate for Delegate {
|
|||
|
||||
impl PickerStory {
|
||||
pub fn new(cx: &mut WindowContext) -> View<Self> {
|
||||
cx.build_view(|cx| {
|
||||
cx.new_view(|cx| {
|
||||
cx.bind_keys([
|
||||
KeyBinding::new("up", menu::SelectPrev, Some("picker")),
|
||||
KeyBinding::new("pageup", menu::SelectFirst, Some("picker")),
|
||||
|
@ -136,7 +136,7 @@ impl PickerStory {
|
|||
]);
|
||||
|
||||
PickerStory {
|
||||
picker: cx.build_view(|cx| {
|
||||
picker: cx.new_view(|cx| {
|
||||
let mut delegate = Delegate::new(&[
|
||||
"Baguette (France)",
|
||||
"Baklava (Turkey)",
|
||||
|
|
|
@ -6,7 +6,7 @@ pub struct ScrollStory;
|
|||
|
||||
impl ScrollStory {
|
||||
pub fn view(cx: &mut WindowContext) -> View<ScrollStory> {
|
||||
cx.build_view(|_cx| ScrollStory)
|
||||
cx.new_view(|_cx| ScrollStory)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ pub struct TextStory;
|
|||
|
||||
impl TextStory {
|
||||
pub fn view(cx: &mut WindowContext) -> View<Self> {
|
||||
cx.build_view(|_cx| Self)
|
||||
cx.new_view(|_cx| Self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,30 +42,28 @@ impl ComponentStory {
|
|||
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
|
||||
match self {
|
||||
Self::AutoHeightEditor => AutoHeightEditorStory::new(cx).into(),
|
||||
Self::Avatar => cx.build_view(|_| ui::AvatarStory).into(),
|
||||
Self::Button => cx.build_view(|_| ui::ButtonStory).into(),
|
||||
Self::Checkbox => cx.build_view(|_| ui::CheckboxStory).into(),
|
||||
Self::ContextMenu => cx.build_view(|_| ui::ContextMenuStory).into(),
|
||||
Self::Cursor => cx.build_view(|_| crate::stories::CursorStory).into(),
|
||||
Self::Disclosure => cx.build_view(|_| ui::DisclosureStory).into(),
|
||||
Self::Avatar => cx.new_view(|_| ui::AvatarStory).into(),
|
||||
Self::Button => cx.new_view(|_| ui::ButtonStory).into(),
|
||||
Self::Checkbox => cx.new_view(|_| ui::CheckboxStory).into(),
|
||||
Self::ContextMenu => cx.new_view(|_| ui::ContextMenuStory).into(),
|
||||
Self::Cursor => cx.new_view(|_| crate::stories::CursorStory).into(),
|
||||
Self::Disclosure => cx.new_view(|_| ui::DisclosureStory).into(),
|
||||
Self::Focus => FocusStory::view(cx).into(),
|
||||
Self::Icon => cx.build_view(|_| ui::IconStory).into(),
|
||||
Self::IconButton => cx.build_view(|_| ui::IconButtonStory).into(),
|
||||
Self::Keybinding => cx.build_view(|_| ui::KeybindingStory).into(),
|
||||
Self::Label => cx.build_view(|_| ui::LabelStory).into(),
|
||||
Self::List => cx.build_view(|_| ui::ListStory).into(),
|
||||
Self::ListHeader => cx.build_view(|_| ui::ListHeaderStory).into(),
|
||||
Self::ListItem => cx.build_view(|_| ui::ListItemStory).into(),
|
||||
Self::OverflowScroll => cx
|
||||
.build_view(|_| crate::stories::OverflowScrollStory)
|
||||
.into(),
|
||||
Self::Icon => cx.new_view(|_| ui::IconStory).into(),
|
||||
Self::IconButton => cx.new_view(|_| ui::IconButtonStory).into(),
|
||||
Self::Keybinding => cx.new_view(|_| ui::KeybindingStory).into(),
|
||||
Self::Label => cx.new_view(|_| ui::LabelStory).into(),
|
||||
Self::List => cx.new_view(|_| ui::ListStory).into(),
|
||||
Self::ListHeader => cx.new_view(|_| ui::ListHeaderStory).into(),
|
||||
Self::ListItem => cx.new_view(|_| ui::ListItemStory).into(),
|
||||
Self::OverflowScroll => cx.new_view(|_| crate::stories::OverflowScrollStory).into(),
|
||||
Self::Scroll => ScrollStory::view(cx).into(),
|
||||
Self::Text => TextStory::view(cx).into(),
|
||||
Self::Tab => cx.build_view(|_| ui::TabStory).into(),
|
||||
Self::TabBar => cx.build_view(|_| ui::TabBarStory).into(),
|
||||
Self::ToggleButton => cx.build_view(|_| ui::ToggleButtonStory).into(),
|
||||
Self::ViewportUnits => cx.build_view(|_| crate::stories::ViewportUnitsStory).into(),
|
||||
Self::ZIndex => cx.build_view(|_| ZIndexStory).into(),
|
||||
Self::Tab => cx.new_view(|_| ui::TabStory).into(),
|
||||
Self::TabBar => cx.new_view(|_| ui::TabBarStory).into(),
|
||||
Self::ToggleButton => cx.new_view(|_| ui::ToggleButtonStory).into(),
|
||||
Self::ViewportUnits => cx.new_view(|_| crate::stories::ViewportUnitsStory).into(),
|
||||
Self::ZIndex => cx.new_view(|_| ZIndexStory).into(),
|
||||
Self::Picker => PickerStory::new(cx).into(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ fn main() {
|
|||
let ui_font_size = ThemeSettings::get_global(cx).ui_font_size;
|
||||
cx.set_rem_size(ui_font_size);
|
||||
|
||||
cx.build_view(|cx| StoryWrapper::new(selector.story(cx)))
|
||||
cx.new_view(|cx| StoryWrapper::new(selector.story(cx)))
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ pub struct TerminalPanel {
|
|||
impl TerminalPanel {
|
||||
fn new(workspace: &Workspace, cx: &mut ViewContext<Self>) -> Self {
|
||||
let terminal_panel = cx.view().clone();
|
||||
let pane = cx.build_view(|cx| {
|
||||
let pane = cx.new_view(|cx| {
|
||||
let mut pane = Pane::new(
|
||||
workspace.weak_handle(),
|
||||
workspace.project().clone(),
|
||||
|
@ -147,7 +147,7 @@ impl TerminalPanel {
|
|||
.flatten();
|
||||
|
||||
let (panel, pane, items) = workspace.update(&mut cx, |workspace, cx| {
|
||||
let panel = cx.build_view(|cx| TerminalPanel::new(workspace, cx));
|
||||
let panel = cx.new_view(|cx| TerminalPanel::new(workspace, cx));
|
||||
let items = if let Some(serialized_panel) = serialized_panel.as_ref() {
|
||||
panel.update(cx, |panel, cx| {
|
||||
cx.notify();
|
||||
|
@ -272,7 +272,7 @@ impl TerminalPanel {
|
|||
.create_terminal(working_directory, window, cx)
|
||||
.log_err()
|
||||
}) {
|
||||
let terminal = Box::new(cx.build_view(|cx| {
|
||||
let terminal = Box::new(cx.new_view(|cx| {
|
||||
TerminalView::new(
|
||||
terminal,
|
||||
workspace.weak_handle(),
|
||||
|
|
|
@ -118,7 +118,7 @@ impl TerminalView {
|
|||
.notify_err(workspace, cx);
|
||||
|
||||
if let Some(terminal) = terminal {
|
||||
let view = cx.build_view(|cx| {
|
||||
let view = cx.new_view(|cx| {
|
||||
TerminalView::new(
|
||||
terminal,
|
||||
workspace.weak_handle(),
|
||||
|
@ -765,7 +765,7 @@ impl Item for TerminalView {
|
|||
project.create_terminal(cwd, window, cx)
|
||||
})??;
|
||||
pane.update(&mut cx, |_, cx| {
|
||||
cx.build_view(|cx| TerminalView::new(terminal, workspace, workspace_id, cx))
|
||||
cx.new_view(|cx| TerminalView::new(terminal, workspace, workspace_id, cx))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ impl Render for ThemeSelector {
|
|||
|
||||
impl ThemeSelector {
|
||||
pub fn new(delegate: ThemeSelectorDelegate, cx: &mut ViewContext<Self>) -> Self {
|
||||
let picker = cx.build_view(|cx| Picker::new(delegate, cx));
|
||||
let picker = cx.new_view(|cx| Picker::new(delegate, cx));
|
||||
Self { picker }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ impl ContextMenu {
|
|||
cx: &mut WindowContext,
|
||||
f: impl FnOnce(Self, &mut WindowContext) -> Self,
|
||||
) -> View<Self> {
|
||||
cx.build_view(|cx| {
|
||||
cx.new_view(|cx| {
|
||||
let focus_handle = cx.focus_handle();
|
||||
let _on_blur_subscription = cx.on_blur(&focus_handle, |this: &mut ContextMenu, cx| {
|
||||
this.cancel(&menu::Cancel, cx)
|
||||
|
|
|
@ -13,7 +13,7 @@ pub struct Tooltip {
|
|||
|
||||
impl Tooltip {
|
||||
pub fn text(title: impl Into<SharedString>, cx: &mut WindowContext) -> AnyView {
|
||||
cx.build_view(|_cx| Self {
|
||||
cx.new_view(|_cx| Self {
|
||||
title: title.into(),
|
||||
meta: None,
|
||||
key_binding: None,
|
||||
|
@ -26,7 +26,7 @@ impl Tooltip {
|
|||
action: &dyn Action,
|
||||
cx: &mut WindowContext,
|
||||
) -> AnyView {
|
||||
cx.build_view(|cx| Self {
|
||||
cx.new_view(|cx| Self {
|
||||
title: title.into(),
|
||||
meta: None,
|
||||
key_binding: KeyBinding::for_action(action, cx),
|
||||
|
@ -40,7 +40,7 @@ impl Tooltip {
|
|||
meta: impl Into<SharedString>,
|
||||
cx: &mut WindowContext,
|
||||
) -> AnyView {
|
||||
cx.build_view(|cx| Self {
|
||||
cx.new_view(|cx| Self {
|
||||
title: title.into(),
|
||||
meta: Some(meta.into()),
|
||||
key_binding: action.and_then(|action| KeyBinding::for_action(action, cx)),
|
||||
|
|
|
@ -35,7 +35,7 @@ pub struct BranchList {
|
|||
|
||||
impl BranchList {
|
||||
fn new(delegate: BranchListDelegate, rem_width: f32, cx: &mut ViewContext<Self>) -> Self {
|
||||
let picker = cx.build_view(|cx| Picker::new(delegate, cx));
|
||||
let picker = cx.new_view(|cx| Picker::new(delegate, cx));
|
||||
let _subscription = cx.subscribe(&picker, |_, _, _, cx| cx.emit(DismissEvent));
|
||||
Self {
|
||||
picker,
|
||||
|
@ -84,7 +84,7 @@ pub fn build_branch_list(
|
|||
let delegate = workspace.update(cx, |workspace, cx| {
|
||||
BranchListDelegate::new(workspace, cx.view().clone(), 29, cx)
|
||||
})?;
|
||||
Ok(cx.build_view(move |cx| BranchList::new(delegate, 20., cx)))
|
||||
Ok(cx.new_view(move |cx| BranchList::new(delegate, 20., cx)))
|
||||
}
|
||||
|
||||
pub struct BranchListDelegate {
|
||||
|
|
|
@ -77,7 +77,7 @@ mod test {
|
|||
async fn test_blur_focus(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = VimTestContext::new(cx, true).await;
|
||||
|
||||
let buffer = cx.build_model(|_| Buffer::new(0, 0, "a = 1\nb = 2\n"));
|
||||
let buffer = cx.new_model(|_| Buffer::new(0, 0, "a = 1\nb = 2\n"));
|
||||
let window2 = cx.add_window(|cx| Editor::for_buffer(buffer, None, cx));
|
||||
let editor2 = cx
|
||||
.update(|cx| {
|
||||
|
|
|
@ -57,7 +57,7 @@ impl<'a> VimTestContext<'a> {
|
|||
observe_keystrokes(cx);
|
||||
workspace.active_pane().update(cx, |pane, cx| {
|
||||
pane.toolbar().update(cx, |toolbar, cx| {
|
||||
let buffer_search_bar = cx.build_view(BufferSearchBar::new);
|
||||
let buffer_search_bar = cx.new_view(BufferSearchBar::new);
|
||||
toolbar.add_item(buffer_search_bar, cx);
|
||||
// todo!();
|
||||
// let project_search_bar = cx.add_view(|_| ProjectSearchBar::new());
|
||||
|
@ -65,7 +65,7 @@ impl<'a> VimTestContext<'a> {
|
|||
})
|
||||
});
|
||||
workspace.status_bar().update(cx, |status_bar, cx| {
|
||||
let vim_mode_indicator = cx.build_view(ModeIndicator::new);
|
||||
let vim_mode_indicator = cx.new_view(ModeIndicator::new);
|
||||
status_bar.add_right_item(vim_mode_indicator, cx);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -54,7 +54,7 @@ impl BaseKeymapSelector {
|
|||
delegate: BaseKeymapSelectorDelegate,
|
||||
cx: &mut ViewContext<BaseKeymapSelector>,
|
||||
) -> Self {
|
||||
let picker = cx.build_view(|cx| Picker::new(delegate, cx));
|
||||
let picker = cx.new_view(|cx| Picker::new(delegate, cx));
|
||||
let focus_handle = cx.focus_handle();
|
||||
Self {
|
||||
focus_handle,
|
||||
|
|
|
@ -27,7 +27,7 @@ pub fn init(cx: &mut AppContext) {
|
|||
|
||||
cx.observe_new_views(|workspace: &mut Workspace, _cx| {
|
||||
workspace.register_action(|workspace, _: &Welcome, cx| {
|
||||
let welcome_page = cx.build_view(|cx| WelcomePage::new(workspace, cx));
|
||||
let welcome_page = cx.new_view(|cx| WelcomePage::new(workspace, cx));
|
||||
workspace.add_item(Box::new(welcome_page), cx)
|
||||
});
|
||||
})
|
||||
|
@ -39,7 +39,7 @@ pub fn init(cx: &mut AppContext) {
|
|||
pub fn show_welcome_view(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
||||
open_new(&app_state, cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Left, cx);
|
||||
let welcome_page = cx.build_view(|cx| WelcomePage::new(workspace, cx));
|
||||
let welcome_page = cx.new_view(|cx| WelcomePage::new(workspace, cx));
|
||||
workspace.add_item_to_center(Box::new(welcome_page.clone()), cx);
|
||||
cx.focus_view(&welcome_page);
|
||||
cx.notify();
|
||||
|
@ -270,7 +270,7 @@ impl Item for WelcomePage {
|
|||
_workspace_id: WorkspaceId,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<View<Self>> {
|
||||
Some(cx.build_view(|cx| WelcomePage {
|
||||
Some(cx.new_view(|cx| WelcomePage {
|
||||
focus_handle: cx.focus_handle(),
|
||||
workspace: self.workspace.clone(),
|
||||
_settings_subscription: cx.observe_global::<SettingsStore>(move |_, cx| cx.notify()),
|
||||
|
|
|
@ -195,7 +195,7 @@ impl Dock {
|
|||
pub fn new(position: DockPosition, cx: &mut ViewContext<Workspace>) -> View<Self> {
|
||||
let focus_handle = cx.focus_handle();
|
||||
|
||||
let dock = cx.build_view(|cx: &mut ViewContext<Self>| {
|
||||
let dock = cx.new_view(|cx: &mut ViewContext<Self>| {
|
||||
let focus_subscription = cx.on_focus(&focus_handle, |dock, cx| {
|
||||
if let Some(active_entry) = dock.panel_entries.get(dock.active_panel_index) {
|
||||
active_entry.panel.focus_handle(cx).focus(cx)
|
||||
|
@ -514,7 +514,7 @@ impl Render for Dock {
|
|||
.id("resize-handle")
|
||||
.on_drag(DraggedDock(position), |dock, cx| {
|
||||
cx.stop_propagation();
|
||||
cx.build_view(|_| dock.clone())
|
||||
cx.new_view(|_| dock.clone())
|
||||
})
|
||||
.on_click(cx.listener(|v, e: &ClickEvent, cx| {
|
||||
if e.down.button == MouseButton::Left && e.down.click_count == 2 {
|
||||
|
|
|
@ -831,14 +831,14 @@ pub mod test {
|
|||
worktree_id: WorktreeId::from_usize(0),
|
||||
path: Path::new(path).into(),
|
||||
});
|
||||
cx.build_model(|_| Self {
|
||||
cx.new_model(|_| Self {
|
||||
entry_id,
|
||||
project_path,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn new_untitled(cx: &mut AppContext) -> Model<Self> {
|
||||
cx.build_model(|_| Self {
|
||||
cx.new_model(|_| Self {
|
||||
project_path: None,
|
||||
entry_id: None,
|
||||
})
|
||||
|
@ -987,7 +987,7 @@ pub mod test {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
Some(cx.build_view(|cx| Self {
|
||||
Some(cx.new_view(|cx| Self {
|
||||
state: self.state.clone(),
|
||||
label: self.label.clone(),
|
||||
save_count: self.save_count,
|
||||
|
@ -1063,7 +1063,7 @@ pub mod test {
|
|||
_item_id: ItemId,
|
||||
cx: &mut ViewContext<Pane>,
|
||||
) -> Task<anyhow::Result<View<Self>>> {
|
||||
let view = cx.build_view(|cx| Self::new_deserialized(workspace_id, cx));
|
||||
let view = cx.new_view(|cx| Self::new_deserialized(workspace_id, cx));
|
||||
Task::Ready(Some(anyhow::Ok(view)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ impl ModalLayer {
|
|||
return;
|
||||
}
|
||||
}
|
||||
let new_modal = cx.build_view(build_view);
|
||||
let new_modal = cx.new_view(build_view);
|
||||
self.show_modal(new_modal, cx);
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ impl Workspace {
|
|||
E: std::fmt::Debug,
|
||||
{
|
||||
self.show_notification(0, cx, |cx| {
|
||||
cx.build_view(|_cx| {
|
||||
cx.new_view(|_cx| {
|
||||
simple_message_notification::MessageNotification::new(format!("Error: {err:?}"))
|
||||
})
|
||||
});
|
||||
|
@ -134,7 +134,7 @@ impl Workspace {
|
|||
pub fn show_toast(&mut self, toast: Toast, cx: &mut ViewContext<Self>) {
|
||||
self.dismiss_notification::<simple_message_notification::MessageNotification>(toast.id, cx);
|
||||
self.show_notification(toast.id, cx, |cx| {
|
||||
cx.build_view(|_cx| match toast.on_click.as_ref() {
|
||||
cx.new_view(|_cx| match toast.on_click.as_ref() {
|
||||
Some((click_msg, on_click)) => {
|
||||
let on_click = on_click.clone();
|
||||
simple_message_notification::MessageNotification::new(toast.msg.clone())
|
||||
|
|
|
@ -361,7 +361,7 @@ impl Pane {
|
|||
pane: handle.clone(),
|
||||
next_timestamp,
|
||||
}))),
|
||||
toolbar: cx.build_view(|_| Toolbar::new()),
|
||||
toolbar: cx.new_view(|_| Toolbar::new()),
|
||||
new_item_menu: None,
|
||||
split_item_menu: None,
|
||||
tab_bar_scroll_handle: ScrollHandle::new(),
|
||||
|
@ -1540,7 +1540,7 @@ impl Pane {
|
|||
is_active,
|
||||
ix,
|
||||
},
|
||||
|tab, cx| cx.build_view(|_| tab.clone()),
|
||||
|tab, cx| cx.new_view(|_| tab.clone()),
|
||||
)
|
||||
.drag_over::<DraggedTab>(|tab| tab.bg(cx.theme().colors().drop_target_background))
|
||||
.drag_over::<ProjectEntryId>(|tab| tab.bg(cx.theme().colors().drop_target_background))
|
||||
|
@ -2241,7 +2241,7 @@ mod tests {
|
|||
set_labeled_items(&pane, ["A", "B*", "C"], cx);
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.add_item(
|
||||
Box::new(cx.build_view(|cx| TestItem::new(cx).with_label("D"))),
|
||||
Box::new(cx.new_view(|cx| TestItem::new(cx).with_label("D"))),
|
||||
false,
|
||||
false,
|
||||
Some(0),
|
||||
|
@ -2254,7 +2254,7 @@ mod tests {
|
|||
set_labeled_items(&pane, ["A", "B*", "C"], cx);
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.add_item(
|
||||
Box::new(cx.build_view(|cx| TestItem::new(cx).with_label("D"))),
|
||||
Box::new(cx.new_view(|cx| TestItem::new(cx).with_label("D"))),
|
||||
false,
|
||||
false,
|
||||
Some(2),
|
||||
|
@ -2267,7 +2267,7 @@ mod tests {
|
|||
set_labeled_items(&pane, ["A", "B*", "C"], cx);
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.add_item(
|
||||
Box::new(cx.build_view(|cx| TestItem::new(cx).with_label("D"))),
|
||||
Box::new(cx.new_view(|cx| TestItem::new(cx).with_label("D"))),
|
||||
false,
|
||||
false,
|
||||
Some(5),
|
||||
|
@ -2281,7 +2281,7 @@ mod tests {
|
|||
set_labeled_items(&pane, ["A*", "B", "C"], cx);
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.add_item(
|
||||
Box::new(cx.build_view(|cx| TestItem::new(cx).with_label("D"))),
|
||||
Box::new(cx.new_view(|cx| TestItem::new(cx).with_label("D"))),
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
|
@ -2294,7 +2294,7 @@ mod tests {
|
|||
set_labeled_items(&pane, ["A", "B", "C*"], cx);
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.add_item(
|
||||
Box::new(cx.build_view(|cx| TestItem::new(cx).with_label("D"))),
|
||||
Box::new(cx.new_view(|cx| TestItem::new(cx).with_label("D"))),
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
|
@ -2391,7 +2391,7 @@ mod tests {
|
|||
// singleton view
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.add_item(
|
||||
Box::new(cx.build_view(|cx| {
|
||||
Box::new(cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_singleton(true)
|
||||
.with_label("buffer 1")
|
||||
|
@ -2408,7 +2408,7 @@ mod tests {
|
|||
// new singleton view with the same project entry
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.add_item(
|
||||
Box::new(cx.build_view(|cx| {
|
||||
Box::new(cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_singleton(true)
|
||||
.with_label("buffer 1")
|
||||
|
@ -2425,7 +2425,7 @@ mod tests {
|
|||
// new singleton view with different project entry
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.add_item(
|
||||
Box::new(cx.build_view(|cx| {
|
||||
Box::new(cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_singleton(true)
|
||||
.with_label("buffer 2")
|
||||
|
@ -2442,7 +2442,7 @@ mod tests {
|
|||
// new multibuffer view with the same project entry
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.add_item(
|
||||
Box::new(cx.build_view(|cx| {
|
||||
Box::new(cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_singleton(false)
|
||||
.with_label("multibuffer 1")
|
||||
|
@ -2459,7 +2459,7 @@ mod tests {
|
|||
// another multibuffer view with the same project entry
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.add_item(
|
||||
Box::new(cx.build_view(|cx| {
|
||||
Box::new(cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_singleton(false)
|
||||
.with_label("multibuffer 1b")
|
||||
|
@ -2673,7 +2673,7 @@ mod tests {
|
|||
) -> Box<View<TestItem>> {
|
||||
pane.update(cx, |pane, cx| {
|
||||
let labeled_item = Box::new(
|
||||
cx.build_view(|cx| TestItem::new(cx).with_label(label).with_dirty(is_dirty)),
|
||||
cx.new_view(|cx| TestItem::new(cx).with_label(label).with_dirty(is_dirty)),
|
||||
);
|
||||
pane.add_item(labeled_item.clone(), false, false, None, cx);
|
||||
labeled_item
|
||||
|
@ -2696,8 +2696,7 @@ mod tests {
|
|||
active_item_index = index;
|
||||
}
|
||||
|
||||
let labeled_item =
|
||||
Box::new(cx.build_view(|cx| TestItem::new(cx).with_label(label)));
|
||||
let labeled_item = Box::new(cx.new_view(|cx| TestItem::new(cx).with_label(label)));
|
||||
pane.add_item(labeled_item.clone(), false, false, None, cx);
|
||||
index += 1;
|
||||
labeled_item
|
||||
|
|
|
@ -117,7 +117,7 @@ impl Item for SharedScreen {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<View<Self>> {
|
||||
let track = self.track.upgrade()?;
|
||||
Some(cx.build_view(|cx| Self::new(&track, self.peer_id, self.user.clone(), cx)))
|
||||
Some(cx.new_view(|cx| Self::new(&track, self.peer_id, self.user.clone(), cx)))
|
||||
}
|
||||
|
||||
fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) {
|
||||
|
|
|
@ -261,7 +261,7 @@ pub fn register_project_item<I: ProjectItem>(cx: &mut AppContext) {
|
|||
let builders = cx.default_global::<ProjectItemBuilders>();
|
||||
builders.insert(TypeId::of::<I::Item>(), |project, model, cx| {
|
||||
let item = model.downcast::<I::Item>().unwrap();
|
||||
Box::new(cx.build_view(|cx| I::for_project_item(project, item, cx)))
|
||||
Box::new(cx.new_view(|cx| I::for_project_item(project, item, cx)))
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -358,8 +358,8 @@ impl AppState {
|
|||
let languages = Arc::new(LanguageRegistry::test());
|
||||
let http_client = util::http::FakeHttpClient::with_404_response();
|
||||
let client = Client::new(http_client.clone(), cx);
|
||||
let user_store = cx.build_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
let user_store = cx.new_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let workspace_store = cx.new_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
|
||||
theme::init(theme::LoadThemes::JustBase, cx);
|
||||
client::init(&client, cx);
|
||||
|
@ -519,7 +519,7 @@ impl Workspace {
|
|||
}
|
||||
|
||||
project::Event::Notification(message) => this.show_notification(0, cx, |cx| {
|
||||
cx.build_view(|_| MessageNotification::new(message.clone()))
|
||||
cx.new_view(|_| MessageNotification::new(message.clone()))
|
||||
}),
|
||||
|
||||
_ => {}
|
||||
|
@ -537,7 +537,7 @@ impl Workspace {
|
|||
let weak_handle = cx.view().downgrade();
|
||||
let pane_history_timestamp = Arc::new(AtomicUsize::new(0));
|
||||
|
||||
let center_pane = cx.build_view(|cx| {
|
||||
let center_pane = cx.new_view(|cx| {
|
||||
Pane::new(
|
||||
weak_handle.clone(),
|
||||
project.clone(),
|
||||
|
@ -589,10 +589,10 @@ impl Workspace {
|
|||
let left_dock = Dock::new(DockPosition::Left, cx);
|
||||
let bottom_dock = Dock::new(DockPosition::Bottom, cx);
|
||||
let right_dock = Dock::new(DockPosition::Right, cx);
|
||||
let left_dock_buttons = cx.build_view(|cx| PanelButtons::new(left_dock.clone(), cx));
|
||||
let bottom_dock_buttons = cx.build_view(|cx| PanelButtons::new(bottom_dock.clone(), cx));
|
||||
let right_dock_buttons = cx.build_view(|cx| PanelButtons::new(right_dock.clone(), cx));
|
||||
let status_bar = cx.build_view(|cx| {
|
||||
let left_dock_buttons = cx.new_view(|cx| PanelButtons::new(left_dock.clone(), cx));
|
||||
let bottom_dock_buttons = cx.new_view(|cx| PanelButtons::new(bottom_dock.clone(), cx));
|
||||
let right_dock_buttons = cx.new_view(|cx| PanelButtons::new(right_dock.clone(), cx));
|
||||
let status_bar = cx.new_view(|cx| {
|
||||
let mut status_bar = StatusBar::new(¢er_pane.clone(), cx);
|
||||
status_bar.add_left_item(left_dock_buttons, cx);
|
||||
status_bar.add_right_item(right_dock_buttons, cx);
|
||||
|
@ -600,7 +600,7 @@ impl Workspace {
|
|||
status_bar
|
||||
});
|
||||
|
||||
let modal_layer = cx.build_view(|_| ModalLayer::new());
|
||||
let modal_layer = cx.new_view(|_| ModalLayer::new());
|
||||
|
||||
let mut active_call = None;
|
||||
if cx.has_global::<Model<ActiveCall>>() {
|
||||
|
@ -800,7 +800,7 @@ impl Workspace {
|
|||
let workspace_id = workspace_id.clone();
|
||||
let project_handle = project_handle.clone();
|
||||
move |cx| {
|
||||
cx.build_view(|cx| {
|
||||
cx.new_view(|cx| {
|
||||
Workspace::new(workspace_id, project_handle, app_state, cx)
|
||||
})
|
||||
}
|
||||
|
@ -1718,7 +1718,7 @@ impl Workspace {
|
|||
}
|
||||
|
||||
fn add_pane(&mut self, cx: &mut ViewContext<Self>) -> View<Pane> {
|
||||
let pane = cx.build_view(|cx| {
|
||||
let pane = cx.new_view(|cx| {
|
||||
Pane::new(
|
||||
self.weak_handle(),
|
||||
self.project.clone(),
|
||||
|
@ -1915,8 +1915,7 @@ impl Workspace {
|
|||
return item;
|
||||
}
|
||||
|
||||
let item =
|
||||
cx.build_view(|cx| T::for_project_item(self.project().clone(), project_item, cx));
|
||||
let item = cx.new_view(|cx| T::for_project_item(self.project().clone(), project_item, cx));
|
||||
self.add_item(Box::new(item.clone()), cx);
|
||||
item
|
||||
}
|
||||
|
@ -1940,8 +1939,7 @@ impl Workspace {
|
|||
return item;
|
||||
}
|
||||
|
||||
let item =
|
||||
cx.build_view(|cx| T::for_project_item(self.project().clone(), project_item, cx));
|
||||
let item = cx.new_view(|cx| T::for_project_item(self.project().clone(), project_item, cx));
|
||||
self.split_item(SplitDirection::Right, Box::new(item.clone()), cx);
|
||||
item
|
||||
}
|
||||
|
@ -2852,7 +2850,7 @@ impl Workspace {
|
|||
}
|
||||
}
|
||||
|
||||
Some(cx.build_view(|cx| SharedScreen::new(&track, peer_id, user.clone(), cx)))
|
||||
Some(cx.new_view(|cx| SharedScreen::new(&track, peer_id, user.clone(), cx)))
|
||||
}
|
||||
|
||||
pub fn on_window_activation_changed(&mut self, cx: &mut ViewContext<Self>) {
|
||||
|
@ -3265,7 +3263,7 @@ impl Workspace {
|
|||
let client = project.read(cx).client();
|
||||
let user_store = project.read(cx).user_store();
|
||||
|
||||
let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
let workspace_store = cx.new_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
let app_state = Arc::new(AppState {
|
||||
languages: project.read(cx).languages().clone(),
|
||||
workspace_store,
|
||||
|
@ -3468,7 +3466,7 @@ fn notify_if_database_failed(workspace: WindowHandle<Workspace>, cx: &mut AsyncA
|
|||
.update(cx, |workspace, cx| {
|
||||
if (*db::ALL_FILE_DB_FAILED).load(std::sync::atomic::Ordering::Acquire) {
|
||||
workspace.show_notification_once(0, cx, |cx| {
|
||||
cx.build_view(|_| {
|
||||
cx.new_view(|_| {
|
||||
MessageNotification::new("Failed to load the database file.")
|
||||
.with_click_message("Click to let us know about this error")
|
||||
.on_click(|cx| cx.open_url(REPORT_ISSUE_URL))
|
||||
|
@ -4180,7 +4178,7 @@ pub fn join_remote_project(
|
|||
cx.update(|cx| {
|
||||
let options = (app_state.build_window_options)(window_bounds_override, None, cx);
|
||||
cx.open_window(options, |cx| {
|
||||
cx.build_view(|cx| Workspace::new(0, project, app_state.clone(), cx))
|
||||
cx.new_view(|cx| Workspace::new(0, project, app_state.clone(), cx))
|
||||
})
|
||||
})?
|
||||
};
|
||||
|
@ -4354,7 +4352,7 @@ mod tests {
|
|||
let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project.clone(), cx));
|
||||
|
||||
// Adding an item with no ambiguity renders the tab without detail.
|
||||
let item1 = cx.build_view(|cx| {
|
||||
let item1 = cx.new_view(|cx| {
|
||||
let mut item = TestItem::new(cx);
|
||||
item.tab_descriptions = Some(vec!["c", "b1/c", "a/b1/c"]);
|
||||
item
|
||||
|
@ -4366,7 +4364,7 @@ mod tests {
|
|||
|
||||
// Adding an item that creates ambiguity increases the level of detail on
|
||||
// both tabs.
|
||||
let item2 = cx.build_view(|cx| {
|
||||
let item2 = cx.new_view(|cx| {
|
||||
let mut item = TestItem::new(cx);
|
||||
item.tab_descriptions = Some(vec!["c", "b2/c", "a/b2/c"]);
|
||||
item
|
||||
|
@ -4380,7 +4378,7 @@ mod tests {
|
|||
// Adding an item that creates ambiguity increases the level of detail only
|
||||
// on the ambiguous tabs. In this case, the ambiguity can't be resolved so
|
||||
// we stop at the highest detail available.
|
||||
let item3 = cx.build_view(|cx| {
|
||||
let item3 = cx.new_view(|cx| {
|
||||
let mut item = TestItem::new(cx);
|
||||
item.tab_descriptions = Some(vec!["c", "b2/c", "a/b2/c"]);
|
||||
item
|
||||
|
@ -4421,10 +4419,10 @@ mod tests {
|
|||
project.worktrees().next().unwrap().read(cx).id()
|
||||
});
|
||||
|
||||
let item1 = cx.build_view(|cx| {
|
||||
let item1 = cx.new_view(|cx| {
|
||||
TestItem::new(cx).with_project_items(&[TestProjectItem::new(1, "one.txt", cx)])
|
||||
});
|
||||
let item2 = cx.build_view(|cx| {
|
||||
let item2 = cx.new_view(|cx| {
|
||||
TestItem::new(cx).with_project_items(&[TestProjectItem::new(2, "two.txt", cx)])
|
||||
});
|
||||
|
||||
|
@ -4493,15 +4491,15 @@ mod tests {
|
|||
let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project.clone(), cx));
|
||||
|
||||
// When there are no dirty items, there's nothing to do.
|
||||
let item1 = cx.build_view(|cx| TestItem::new(cx));
|
||||
let item1 = cx.new_view(|cx| TestItem::new(cx));
|
||||
workspace.update(cx, |w, cx| w.add_item(Box::new(item1.clone()), cx));
|
||||
let task = workspace.update(cx, |w, cx| w.prepare_to_close(false, cx));
|
||||
assert!(task.await.unwrap());
|
||||
|
||||
// When there are dirty untitled items, prompt to save each one. If the user
|
||||
// cancels any prompt, then abort.
|
||||
let item2 = cx.build_view(|cx| TestItem::new(cx).with_dirty(true));
|
||||
let item3 = cx.build_view(|cx| {
|
||||
let item2 = cx.new_view(|cx| TestItem::new(cx).with_dirty(true));
|
||||
let item3 = cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_dirty(true)
|
||||
.with_project_items(&[TestProjectItem::new(1, "1.txt", cx)])
|
||||
|
@ -4529,24 +4527,24 @@ mod tests {
|
|||
let project = Project::test(fs, None, cx).await;
|
||||
let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project, cx));
|
||||
|
||||
let item1 = cx.build_view(|cx| {
|
||||
let item1 = cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_dirty(true)
|
||||
.with_project_items(&[TestProjectItem::new(1, "1.txt", cx)])
|
||||
});
|
||||
let item2 = cx.build_view(|cx| {
|
||||
let item2 = cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_dirty(true)
|
||||
.with_conflict(true)
|
||||
.with_project_items(&[TestProjectItem::new(2, "2.txt", cx)])
|
||||
});
|
||||
let item3 = cx.build_view(|cx| {
|
||||
let item3 = cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_dirty(true)
|
||||
.with_conflict(true)
|
||||
.with_project_items(&[TestProjectItem::new(3, "3.txt", cx)])
|
||||
});
|
||||
let item4 = cx.build_view(|cx| {
|
||||
let item4 = cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_dirty(true)
|
||||
.with_project_items(&[TestProjectItem::new_untitled(cx)])
|
||||
|
@ -4638,7 +4636,7 @@ mod tests {
|
|||
// workspace items with multiple project entries.
|
||||
let single_entry_items = (0..=4)
|
||||
.map(|project_entry_id| {
|
||||
cx.build_view(|cx| {
|
||||
cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_dirty(true)
|
||||
.with_project_items(&[TestProjectItem::new(
|
||||
|
@ -4649,7 +4647,7 @@ mod tests {
|
|||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let item_2_3 = cx.build_view(|cx| {
|
||||
let item_2_3 = cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_dirty(true)
|
||||
.with_singleton(false)
|
||||
|
@ -4658,7 +4656,7 @@ mod tests {
|
|||
single_entry_items[3].read(cx).project_items[0].clone(),
|
||||
])
|
||||
});
|
||||
let item_3_4 = cx.build_view(|cx| {
|
||||
let item_3_4 = cx.new_view(|cx| {
|
||||
TestItem::new(cx)
|
||||
.with_dirty(true)
|
||||
.with_singleton(false)
|
||||
|
@ -4745,7 +4743,7 @@ mod tests {
|
|||
let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project, cx));
|
||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
||||
|
||||
let item = cx.build_view(|cx| {
|
||||
let item = cx.new_view(|cx| {
|
||||
TestItem::new(cx).with_project_items(&[TestProjectItem::new(1, "1.txt", cx)])
|
||||
});
|
||||
let item_id = item.entity_id();
|
||||
|
@ -4864,7 +4862,7 @@ mod tests {
|
|||
let project = Project::test(fs, [], cx).await;
|
||||
let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project, cx));
|
||||
|
||||
let item = cx.build_view(|cx| {
|
||||
let item = cx.new_view(|cx| {
|
||||
TestItem::new(cx).with_project_items(&[TestProjectItem::new(1, "1.txt", cx)])
|
||||
});
|
||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
||||
|
|
|
@ -293,7 +293,7 @@ mod tests {
|
|||
});
|
||||
let language = crate::languages::language("c", tree_sitter_c::language(), None).await;
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let mut buffer =
|
||||
Buffer::new(0, cx.entity_id().as_u64(), "").with_language(language, cx);
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ mod tests {
|
|||
});
|
||||
});
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let mut buffer =
|
||||
Buffer::new(0, cx.entity_id().as_u64(), "").with_language(language, cx);
|
||||
let append = |buffer: &mut Buffer, text: &str, cx: &mut ModelContext<Buffer>| {
|
||||
|
|
|
@ -508,7 +508,7 @@ mod tests {
|
|||
|
||||
let language = crate::languages::language("rust", tree_sitter_rust::language(), None).await;
|
||||
|
||||
cx.build_model(|cx| {
|
||||
cx.new_model(|cx| {
|
||||
let mut buffer =
|
||||
Buffer::new(0, cx.entity_id().as_u64(), "").with_language(language, cx);
|
||||
|
||||
|
|
|
@ -378,7 +378,7 @@ mod tests {
|
|||
"#
|
||||
.unindent();
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
language::Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
let outline = buffer.update(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());
|
||||
|
|
|
@ -139,8 +139,8 @@ fn main() {
|
|||
|
||||
language::init(cx);
|
||||
languages::init(languages.clone(), node_runtime.clone(), cx);
|
||||
let user_store = cx.build_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
let user_store = cx.new_model(|cx| UserStore::new(client.clone(), cx));
|
||||
let workspace_store = cx.new_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
|
||||
cx.set_global(client.clone());
|
||||
|
||||
|
|
|
@ -115,17 +115,17 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
|||
// workspace.set_titlebar_item(collab_titlebar_item.into_any(), cx);
|
||||
|
||||
let copilot =
|
||||
cx.build_view(|cx| copilot_button::CopilotButton::new(app_state.fs.clone(), cx));
|
||||
cx.new_view(|cx| copilot_button::CopilotButton::new(app_state.fs.clone(), cx));
|
||||
let diagnostic_summary =
|
||||
cx.build_view(|cx| diagnostics::items::DiagnosticIndicator::new(workspace, cx));
|
||||
cx.new_view(|cx| diagnostics::items::DiagnosticIndicator::new(workspace, cx));
|
||||
let activity_indicator =
|
||||
activity_indicator::ActivityIndicator::new(workspace, app_state.languages.clone(), cx);
|
||||
let active_buffer_language =
|
||||
cx.build_view(|_| language_selector::ActiveBufferLanguage::new(workspace));
|
||||
let vim_mode_indicator = cx.build_view(|cx| vim::ModeIndicator::new(cx));
|
||||
let feedback_button = cx
|
||||
.build_view(|_| feedback::deploy_feedback_button::DeployFeedbackButton::new(workspace));
|
||||
let cursor_position = cx.build_view(|_| editor::items::CursorPosition::new());
|
||||
cx.new_view(|_| language_selector::ActiveBufferLanguage::new(workspace));
|
||||
let vim_mode_indicator = cx.new_view(|cx| vim::ModeIndicator::new(cx));
|
||||
let feedback_button =
|
||||
cx.new_view(|_| feedback::deploy_feedback_button::DeployFeedbackButton::new(workspace));
|
||||
let cursor_position = cx.new_view(|_| editor::items::CursorPosition::new());
|
||||
workspace.status_bar().update(cx, |status_bar, cx| {
|
||||
status_bar.add_left_item(diagnostic_summary, cx);
|
||||
status_bar.add_left_item(activity_indicator, cx);
|
||||
|
@ -412,22 +412,22 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
|||
fn initialize_pane(workspace: &mut Workspace, pane: &View<Pane>, cx: &mut ViewContext<Workspace>) {
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.toolbar().update(cx, |toolbar, cx| {
|
||||
let breadcrumbs = cx.build_view(|_| Breadcrumbs::new());
|
||||
let breadcrumbs = cx.new_view(|_| Breadcrumbs::new());
|
||||
toolbar.add_item(breadcrumbs, cx);
|
||||
let buffer_search_bar = cx.build_view(search::BufferSearchBar::new);
|
||||
let buffer_search_bar = cx.new_view(search::BufferSearchBar::new);
|
||||
toolbar.add_item(buffer_search_bar.clone(), cx);
|
||||
|
||||
let quick_action_bar =
|
||||
cx.build_view(|_| QuickActionBar::new(buffer_search_bar, workspace));
|
||||
cx.new_view(|_| QuickActionBar::new(buffer_search_bar, workspace));
|
||||
toolbar.add_item(quick_action_bar, cx);
|
||||
let diagnostic_editor_controls = cx.build_view(|_| diagnostics::ToolbarControls::new());
|
||||
let diagnostic_editor_controls = cx.new_view(|_| diagnostics::ToolbarControls::new());
|
||||
toolbar.add_item(diagnostic_editor_controls, cx);
|
||||
let project_search_bar = cx.build_view(|_| ProjectSearchBar::new());
|
||||
let project_search_bar = cx.new_view(|_| ProjectSearchBar::new());
|
||||
toolbar.add_item(project_search_bar, cx);
|
||||
let lsp_log_item = cx.build_view(|_| language_tools::LspLogToolbarItemView::new());
|
||||
let lsp_log_item = cx.new_view(|_| language_tools::LspLogToolbarItemView::new());
|
||||
toolbar.add_item(lsp_log_item, cx);
|
||||
let syntax_tree_item =
|
||||
cx.build_view(|_| language_tools::SyntaxTreeToolbarItemView::new());
|
||||
cx.new_view(|_| language_tools::SyntaxTreeToolbarItemView::new());
|
||||
toolbar.add_item(syntax_tree_item, cx);
|
||||
})
|
||||
});
|
||||
|
@ -541,13 +541,15 @@ fn open_log_file(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
|
|||
.expect("creating buffers on a local workspace always succeeds");
|
||||
buffer.update(cx, |buffer, cx| buffer.edit([(0..0, log)], None, cx));
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
MultiBuffer::singleton(buffer, cx).with_title("Log".into())
|
||||
});
|
||||
workspace.add_item(
|
||||
Box::new(cx.build_view(|cx| {
|
||||
Box::new(
|
||||
cx.new_view(|cx| {
|
||||
Editor::for_multibuffer(buffer, Some(project), cx)
|
||||
})),
|
||||
}),
|
||||
),
|
||||
cx,
|
||||
);
|
||||
})
|
||||
|
@ -655,7 +657,7 @@ fn open_local_settings_file(
|
|||
.detach();
|
||||
} else {
|
||||
workspace.show_notification(0, cx, |cx| {
|
||||
cx.build_view(|_| MessageNotification::new("This project has no folders open."))
|
||||
cx.new_view(|_| MessageNotification::new("This project has no folders open."))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -702,11 +704,11 @@ fn open_telemetry_log_file(workspace: &mut Workspace, cx: &mut ViewContext<Works
|
|||
buffer.edit([(buffer.len()..buffer.len(), log_suffix)], None, cx);
|
||||
});
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
MultiBuffer::singleton(buffer, cx).with_title("Telemetry Log".into())
|
||||
});
|
||||
workspace.add_item(
|
||||
Box::new(cx.build_view(|cx| Editor::for_multibuffer(buffer, Some(project), cx))),
|
||||
Box::new(cx.new_view(|cx| Editor::for_multibuffer(buffer, Some(project), cx))),
|
||||
cx,
|
||||
);
|
||||
}).log_err()?;
|
||||
|
@ -736,11 +738,11 @@ fn open_bundled_file(
|
|||
.create_buffer(text.as_ref(), language, cx)
|
||||
.expect("creating buffers on a local workspace always succeeds")
|
||||
});
|
||||
let buffer = cx.build_model(|cx| {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
MultiBuffer::singleton(buffer, cx).with_title(title.into())
|
||||
});
|
||||
workspace.add_item(
|
||||
Box::new(cx.build_view(|cx| {
|
||||
Box::new(cx.new_view(|cx| {
|
||||
Editor::for_multibuffer(buffer, Some(project.clone()), cx)
|
||||
})),
|
||||
cx,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue