Use read-only access methods for read-only entity operations (#31479)
Another follow-up to #31254 Release Notes: - N/A
This commit is contained in:
parent
4a577fff4a
commit
c208532693
79 changed files with 319 additions and 306 deletions
|
@ -553,7 +553,7 @@ impl ContextPickerCompletionProvider {
|
||||||
let url_to_fetch = url_to_fetch.clone();
|
let url_to_fetch = url_to_fetch.clone();
|
||||||
cx.spawn(async move |cx| {
|
cx.spawn(async move |cx| {
|
||||||
if let Some(context) = context_store
|
if let Some(context) = context_store
|
||||||
.update(cx, |context_store, _| {
|
.read_with(cx, |context_store, _| {
|
||||||
context_store.get_url_context(url_to_fetch.clone())
|
context_store.get_url_context(url_to_fetch.clone())
|
||||||
})
|
})
|
||||||
.ok()?
|
.ok()?
|
||||||
|
|
|
@ -1903,7 +1903,7 @@ impl ContextEditor {
|
||||||
.on_click(cx.listener(|this, _event, _window, cx| {
|
.on_click(cx.listener(|this, _event, _window, cx| {
|
||||||
let client = this
|
let client = this
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |workspace, _| workspace.client().clone())
|
.read_with(cx, |workspace, _| workspace.client().clone())
|
||||||
.log_err();
|
.log_err();
|
||||||
|
|
||||||
if let Some(client) = client {
|
if let Some(client) = client {
|
||||||
|
|
|
@ -338,7 +338,7 @@ where
|
||||||
|
|
||||||
let handle = self
|
let handle = self
|
||||||
.active_context_editor
|
.active_context_editor
|
||||||
.update(cx, |this, _| this.slash_menu_handle.clone())
|
.read_with(cx, |this, _| this.slash_menu_handle.clone())
|
||||||
.ok();
|
.ok();
|
||||||
PopoverMenu::new("model-switcher")
|
PopoverMenu::new("model-switcher")
|
||||||
.menu(move |_window, _cx| Some(picker_view.clone()))
|
.menu(move |_window, _cx| Some(picker_view.clone()))
|
||||||
|
|
|
@ -19812,7 +19812,7 @@ impl SemanticsProvider for Entity<Project> {
|
||||||
PrepareRenameResponse::InvalidPosition => None,
|
PrepareRenameResponse::InvalidPosition => None,
|
||||||
PrepareRenameResponse::OnlyUnpreparedRenameSupported => {
|
PrepareRenameResponse::OnlyUnpreparedRenameSupported => {
|
||||||
// Fallback on using TreeSitter info to determine identifier range
|
// Fallback on using TreeSitter info to determine identifier range
|
||||||
buffer.update(cx, |buffer, _| {
|
buffer.read_with(cx, |buffer, _| {
|
||||||
let snapshot = buffer.snapshot();
|
let snapshot = buffer.snapshot();
|
||||||
let (range, kind) = snapshot.surrounding_word(position);
|
let (range, kind) = snapshot.surrounding_word(position);
|
||||||
if kind != Some(CharKind::Word) {
|
if kind != Some(CharKind::Word) {
|
||||||
|
|
|
@ -275,7 +275,7 @@ impl Tool for TerminalTool {
|
||||||
let exit_status = terminal
|
let exit_status = terminal
|
||||||
.update(cx, |terminal, cx| terminal.wait_for_completed_task(cx))?
|
.update(cx, |terminal, cx| terminal.wait_for_completed_task(cx))?
|
||||||
.await;
|
.await;
|
||||||
let (content, content_line_count) = terminal.update(cx, |terminal, _| {
|
let (content, content_line_count) = terminal.read_with(cx, |terminal, _| {
|
||||||
(terminal.get_content(), terminal.total_lines())
|
(terminal.get_content(), terminal.total_lines())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl ActiveCall {
|
||||||
envelope: TypedEnvelope<proto::IncomingCall>,
|
envelope: TypedEnvelope<proto::IncomingCall>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::Ack> {
|
) -> Result<proto::Ack> {
|
||||||
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
|
let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
|
||||||
let call = IncomingCall {
|
let call = IncomingCall {
|
||||||
room_id: envelope.payload.room_id,
|
room_id: envelope.payload.room_id,
|
||||||
participants: user_store
|
participants: user_store
|
||||||
|
|
|
@ -387,7 +387,7 @@ impl ChannelChat {
|
||||||
let loaded_messages = messages_from_proto(proto_messages, &user_store, cx).await?;
|
let loaded_messages = messages_from_proto(proto_messages, &user_store, cx).await?;
|
||||||
|
|
||||||
let first_loaded_message_id = loaded_messages.first().map(|m| m.id);
|
let first_loaded_message_id = loaded_messages.first().map(|m| m.id);
|
||||||
let loaded_message_ids = this.update(cx, |this, _| {
|
let loaded_message_ids = this.read_with(cx, |this, _| {
|
||||||
let mut loaded_message_ids: HashSet<u64> = HashSet::default();
|
let mut loaded_message_ids: HashSet<u64> = HashSet::default();
|
||||||
for message in loaded_messages.iter() {
|
for message in loaded_messages.iter() {
|
||||||
if let Some(saved_message_id) = message.id.into() {
|
if let Some(saved_message_id) = message.id.into() {
|
||||||
|
@ -457,7 +457,7 @@ impl ChannelChat {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let pending_messages = this.update(cx, |this, _| {
|
let pending_messages = this.read_with(cx, |this, _| {
|
||||||
this.pending_messages().cloned().collect::<Vec<_>>()
|
this.pending_messages().cloned().collect::<Vec<_>>()
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ impl ChannelChat {
|
||||||
message: TypedEnvelope<proto::ChannelMessageSent>,
|
message: TypedEnvelope<proto::ChannelMessageSent>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
|
let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
|
||||||
let message = message.payload.message.context("empty message")?;
|
let message = message.payload.message.context("empty message")?;
|
||||||
let message_id = message.id;
|
let message_id = message.id;
|
||||||
|
|
||||||
|
@ -563,7 +563,7 @@ impl ChannelChat {
|
||||||
message: TypedEnvelope<proto::ChannelMessageUpdate>,
|
message: TypedEnvelope<proto::ChannelMessageUpdate>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
|
let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
|
||||||
let message = message.payload.message.context("empty message")?;
|
let message = message.payload.message.context("empty message")?;
|
||||||
|
|
||||||
let message = ChannelMessage::from_proto(message, &user_store, &mut cx).await?;
|
let message = ChannelMessage::from_proto(message, &user_store, &mut cx).await?;
|
||||||
|
|
|
@ -333,7 +333,7 @@ impl ChannelStore {
|
||||||
if let Some(request) = request {
|
if let Some(request) = request {
|
||||||
let response = request.await?;
|
let response = request.await?;
|
||||||
let this = this.upgrade().context("channel store dropped")?;
|
let this = this.upgrade().context("channel store dropped")?;
|
||||||
let user_store = this.update(cx, |this, _| this.user_store.clone())?;
|
let user_store = this.read_with(cx, |this, _| this.user_store.clone())?;
|
||||||
ChannelMessage::from_proto_vec(response.messages, &user_store, cx).await
|
ChannelMessage::from_proto_vec(response.messages, &user_store, cx).await
|
||||||
} else {
|
} else {
|
||||||
Ok(Vec::new())
|
Ok(Vec::new())
|
||||||
|
@ -478,7 +478,7 @@ impl ChannelStore {
|
||||||
hash_map::Entry::Vacant(e) => {
|
hash_map::Entry::Vacant(e) => {
|
||||||
let task = cx
|
let task = cx
|
||||||
.spawn(async move |this, cx| {
|
.spawn(async move |this, cx| {
|
||||||
let channel = this.update(cx, |this, _| {
|
let channel = this.read_with(cx, |this, _| {
|
||||||
this.channel_for_id(channel_id).cloned().ok_or_else(|| {
|
this.channel_for_id(channel_id).cloned().ok_or_else(|| {
|
||||||
Arc::new(anyhow!("no channel for id: {channel_id}"))
|
Arc::new(anyhow!("no channel for id: {channel_id}"))
|
||||||
})
|
})
|
||||||
|
@ -848,7 +848,7 @@ impl ChannelStore {
|
||||||
message: TypedEnvelope<proto::UpdateChannels>,
|
message: TypedEnvelope<proto::UpdateChannels>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
this.update_channels_tx
|
this.update_channels_tx
|
||||||
.unbounded_send(message.payload)
|
.unbounded_send(message.payload)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -1850,7 +1850,7 @@ mod tests {
|
||||||
let (done_tx2, done_rx2) = smol::channel::unbounded();
|
let (done_tx2, done_rx2) = smol::channel::unbounded();
|
||||||
AnyProtoClient::from(client.clone()).add_entity_message_handler(
|
AnyProtoClient::from(client.clone()).add_entity_message_handler(
|
||||||
move |entity: Entity<TestEntity>, _: TypedEnvelope<proto::JoinProject>, mut cx| {
|
move |entity: Entity<TestEntity>, _: TypedEnvelope<proto::JoinProject>, mut cx| {
|
||||||
match entity.update(&mut cx, |entity, _| entity.id).unwrap() {
|
match entity.read_with(&mut cx, |entity, _| entity.id).unwrap() {
|
||||||
1 => done_tx1.try_send(()).unwrap(),
|
1 => done_tx1.try_send(()).unwrap(),
|
||||||
2 => done_tx2.try_send(()).unwrap(),
|
2 => done_tx2.try_send(()).unwrap(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|
|
@ -324,7 +324,7 @@ impl UserStore {
|
||||||
message: TypedEnvelope<proto::UpdateContacts>,
|
message: TypedEnvelope<proto::UpdateContacts>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
this.update_contacts_tx
|
this.update_contacts_tx
|
||||||
.unbounded_send(UpdateContacts::Update(message.payload))
|
.unbounded_send(UpdateContacts::Update(message.payload))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -660,7 +660,7 @@ impl UserStore {
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update(cx, |this, _| {
|
this.read_with(cx, |this, _| {
|
||||||
user_ids
|
user_ids
|
||||||
.iter()
|
.iter()
|
||||||
.map(|user_id| {
|
.map(|user_id| {
|
||||||
|
@ -703,7 +703,7 @@ impl UserStore {
|
||||||
let load_users = self.get_users(vec![user_id], cx);
|
let load_users = self.get_users(vec![user_id], cx);
|
||||||
cx.spawn(async move |this, cx| {
|
cx.spawn(async move |this, cx| {
|
||||||
load_users.await?;
|
load_users.await?;
|
||||||
this.update(cx, |this, _| {
|
this.read_with(cx, |this, _| {
|
||||||
this.users
|
this.users
|
||||||
.get(&user_id)
|
.get(&user_id)
|
||||||
.cloned()
|
.cloned()
|
||||||
|
|
|
@ -352,7 +352,7 @@ impl MessageEditor {
|
||||||
) -> Option<(Anchor, String, Vec<StringMatchCandidate>)> {
|
) -> Option<(Anchor, String, Vec<StringMatchCandidate>)> {
|
||||||
let end_offset = end_anchor.to_offset(buffer.read(cx));
|
let end_offset = end_anchor.to_offset(buffer.read(cx));
|
||||||
|
|
||||||
let query = buffer.update(cx, |buffer, _| {
|
let query = buffer.read_with(cx, |buffer, _| {
|
||||||
let mut query = String::new();
|
let mut query = String::new();
|
||||||
for ch in buffer.reversed_chars_at(end_offset).take(100) {
|
for ch in buffer.reversed_chars_at(end_offset).take(100) {
|
||||||
if ch == '@' {
|
if ch == '@' {
|
||||||
|
@ -410,7 +410,7 @@ impl MessageEditor {
|
||||||
|
|
||||||
let end_offset = end_anchor.to_offset(buffer.read(cx));
|
let end_offset = end_anchor.to_offset(buffer.read(cx));
|
||||||
|
|
||||||
let query = buffer.update(cx, |buffer, _| {
|
let query = buffer.read_with(cx, |buffer, _| {
|
||||||
let mut query = String::new();
|
let mut query = String::new();
|
||||||
for ch in buffer.reversed_chars_at(end_offset).take(100) {
|
for ch in buffer.reversed_chars_at(end_offset).take(100) {
|
||||||
if ch == ':' {
|
if ch == ':' {
|
||||||
|
|
|
@ -428,7 +428,7 @@ impl CollabPanel {
|
||||||
fn serialize(&mut self, cx: &mut Context<Self>) {
|
fn serialize(&mut self, cx: &mut Context<Self>) {
|
||||||
let Some(serialization_key) = self
|
let Some(serialization_key) = self
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |workspace, _| CollabPanel::serialization_key(workspace))
|
.read_with(cx, |workspace, _| CollabPanel::serialization_key(workspace))
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()
|
.flatten()
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -557,7 +557,7 @@ mod tests {
|
||||||
.clone()
|
.clone()
|
||||||
});
|
});
|
||||||
|
|
||||||
palette.update(cx, |palette, _| {
|
palette.read_with(cx, |palette, _| {
|
||||||
assert!(palette.delegate.commands.len() > 5);
|
assert!(palette.delegate.commands.len() > 5);
|
||||||
let is_sorted =
|
let is_sorted =
|
||||||
|actions: &[Command]| actions.windows(2).all(|pair| pair[0].name <= pair[1].name);
|
|actions: &[Command]| actions.windows(2).all(|pair| pair[0].name <= pair[1].name);
|
||||||
|
@ -566,7 +566,7 @@ mod tests {
|
||||||
|
|
||||||
cx.simulate_input("bcksp");
|
cx.simulate_input("bcksp");
|
||||||
|
|
||||||
palette.update(cx, |palette, _| {
|
palette.read_with(cx, |palette, _| {
|
||||||
assert_eq!(palette.delegate.matches[0].string, "editor: backspace");
|
assert_eq!(palette.delegate.matches[0].string, "editor: backspace");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -595,7 +595,7 @@ mod tests {
|
||||||
.picker
|
.picker
|
||||||
.clone()
|
.clone()
|
||||||
});
|
});
|
||||||
palette.update(cx, |palette, _| {
|
palette.read_with(cx, |palette, _| {
|
||||||
assert!(palette.delegate.matches.is_empty())
|
assert!(palette.delegate.matches.is_empty())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,7 @@ mod tests {
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.simulate_input("Editor:: Backspace");
|
cx.simulate_input("Editor:: Backspace");
|
||||||
palette.update(cx, |palette, _| {
|
palette.read_with(cx, |palette, _| {
|
||||||
assert_eq!(palette.delegate.matches[0].string, "editor: backspace");
|
assert_eq!(palette.delegate.matches[0].string, "editor: backspace");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ impl RegisteredBuffer {
|
||||||
Some(buffer.snapshot.version.clone())
|
Some(buffer.snapshot.version.clone())
|
||||||
})
|
})
|
||||||
.ok()??;
|
.ok()??;
|
||||||
let new_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()).ok()?;
|
let new_snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot()).ok()?;
|
||||||
|
|
||||||
let content_changes = cx
|
let content_changes = cx
|
||||||
.background_spawn({
|
.background_spawn({
|
||||||
|
|
|
@ -158,7 +158,7 @@ impl PickerDelegate for AttachModalDelegate {
|
||||||
) -> gpui::Task<()> {
|
) -> gpui::Task<()> {
|
||||||
cx.spawn(async move |this, cx| {
|
cx.spawn(async move |this, cx| {
|
||||||
let Some(processes) = this
|
let Some(processes) = this
|
||||||
.update(cx, |this, _| this.delegate.candidates.clone())
|
.read_with(cx, |this, _| this.delegate.candidates.clone())
|
||||||
.ok()
|
.ok()
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
|
@ -309,7 +309,7 @@ impl PickerDelegate for AttachModalDelegate {
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub(crate) fn _process_names(modal: &AttachModal, cx: &mut Context<AttachModal>) -> Vec<String> {
|
pub(crate) fn _process_names(modal: &AttachModal, cx: &mut Context<AttachModal>) -> Vec<String> {
|
||||||
modal.picker.update(cx, |picker, _| {
|
modal.picker.read_with(cx, |picker, _| {
|
||||||
picker
|
picker
|
||||||
.delegate
|
.delegate
|
||||||
.matches
|
.matches
|
||||||
|
|
|
@ -955,7 +955,7 @@ impl DebugPanel {
|
||||||
cx.spawn_in(window, async move |workspace, cx| {
|
cx.spawn_in(window, async move |workspace, cx| {
|
||||||
let serialized_scenario = serialized_scenario?;
|
let serialized_scenario = serialized_scenario?;
|
||||||
let fs =
|
let fs =
|
||||||
workspace.update(cx, |workspace, _| workspace.app_state().fs.clone())?;
|
workspace.read_with(cx, |workspace, _| workspace.app_state().fs.clone())?;
|
||||||
|
|
||||||
path.push(paths::local_settings_folder_relative_path());
|
path.push(paths::local_settings_folder_relative_path());
|
||||||
if !fs.is_dir(path.as_path()).await {
|
if !fs.is_dir(path.as_path()).await {
|
||||||
|
@ -1014,7 +1014,7 @@ async fn register_session_inner(
|
||||||
session: Entity<Session>,
|
session: Entity<Session>,
|
||||||
cx: &mut AsyncWindowContext,
|
cx: &mut AsyncWindowContext,
|
||||||
) -> Result<Entity<DebugSession>> {
|
) -> Result<Entity<DebugSession>> {
|
||||||
let adapter_name = session.update(cx, |session, _| session.adapter())?;
|
let adapter_name = session.read_with(cx, |session, _| session.adapter())?;
|
||||||
this.update_in(cx, |_, window, cx| {
|
this.update_in(cx, |_, window, cx| {
|
||||||
cx.subscribe_in(
|
cx.subscribe_in(
|
||||||
&session,
|
&session,
|
||||||
|
|
|
@ -319,7 +319,7 @@ pub(crate) fn new_debugger_pane(
|
||||||
if let Some(tab) = dragged_item.downcast_ref::<DraggedTab>() {
|
if let Some(tab) = dragged_item.downcast_ref::<DraggedTab>() {
|
||||||
let is_current_pane = tab.pane == cx.entity();
|
let is_current_pane = tab.pane == cx.entity();
|
||||||
let Some(can_drag_away) = weak_running
|
let Some(can_drag_away) = weak_running
|
||||||
.update(cx, |running_state, _| {
|
.read_with(cx, |running_state, _| {
|
||||||
let current_panes = running_state.panes.panes();
|
let current_panes = running_state.panes.panes();
|
||||||
!current_panes.contains(&&tab.pane)
|
!current_panes.contains(&&tab.pane)
|
||||||
|| current_panes.len() > 1
|
|| current_panes.len() > 1
|
||||||
|
@ -952,7 +952,7 @@ impl RunningState {
|
||||||
let running = cx.entity();
|
let running = cx.entity();
|
||||||
let Ok(project) = self
|
let Ok(project) = self
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |workspace, _| workspace.project().clone())
|
.read_with(cx, |workspace, _| workspace.project().clone())
|
||||||
else {
|
else {
|
||||||
return Task::ready(Err(anyhow!("no workspace")));
|
return Task::ready(Err(anyhow!("no workspace")));
|
||||||
};
|
};
|
||||||
|
|
|
@ -109,7 +109,7 @@ impl BreakpointList {
|
||||||
.update(cx, |this, cx| this.find_or_create_worktree(path, false, cx));
|
.update(cx, |this, cx| this.find_or_create_worktree(path, false, cx));
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
let (worktree, relative_path) = task.await?;
|
let (worktree, relative_path) = task.await?;
|
||||||
let worktree_id = worktree.update(cx, |this, _| this.id())?;
|
let worktree_id = worktree.read_with(cx, |this, _| this.id())?;
|
||||||
let item = this
|
let item = this
|
||||||
.update_in(cx, |this, window, cx| {
|
.update_in(cx, |this, window, cx| {
|
||||||
this.workspace.update(cx, |this, cx| {
|
this.workspace.update(cx, |this, cx| {
|
||||||
|
|
|
@ -280,7 +280,7 @@ impl StackFrameList {
|
||||||
})
|
})
|
||||||
})??
|
})??
|
||||||
.await?;
|
.await?;
|
||||||
let position = buffer.update(cx, |this, _| {
|
let position = buffer.read_with(cx, |this, _| {
|
||||||
this.snapshot().anchor_after(PointUtf16::new(row, 0))
|
this.snapshot().anchor_after(PointUtf16::new(row, 0))
|
||||||
})?;
|
})?;
|
||||||
this.update_in(cx, |this, window, cx| {
|
this.update_in(cx, |this, window, cx| {
|
||||||
|
|
|
@ -148,7 +148,7 @@ impl StackTraceView {
|
||||||
|
|
||||||
let stack_frames = self
|
let stack_frames = self
|
||||||
.stack_frame_list
|
.stack_frame_list
|
||||||
.update(cx, |list, _| list.flatten_entries(false));
|
.read_with(cx, |list, _| list.flatten_entries(false));
|
||||||
|
|
||||||
let frames_to_open: Vec<_> = stack_frames
|
let frames_to_open: Vec<_> = stack_frames
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -237,7 +237,7 @@ impl StackTraceView {
|
||||||
|
|
||||||
let stack_frames = self
|
let stack_frames = self
|
||||||
.stack_frame_list
|
.stack_frame_list
|
||||||
.update(cx, |session, _| session.flatten_entries(false));
|
.read_with(cx, |session, _| session.flatten_entries(false));
|
||||||
|
|
||||||
let active_idx = self
|
let active_idx = self
|
||||||
.selected_stack_frame_id
|
.selected_stack_frame_id
|
||||||
|
|
|
@ -256,7 +256,7 @@ impl DiagnosticBlock {
|
||||||
|
|
||||||
if let Some(diagnostics_editor) = diagnostics_editor {
|
if let Some(diagnostics_editor) = diagnostics_editor {
|
||||||
if let Some(diagnostic) = diagnostics_editor
|
if let Some(diagnostic) = diagnostics_editor
|
||||||
.update(cx, |diagnostics, _| {
|
.read_with(cx, |diagnostics, _| {
|
||||||
diagnostics
|
diagnostics
|
||||||
.diagnostics
|
.diagnostics
|
||||||
.get(&buffer_id)
|
.get(&buffer_id)
|
||||||
|
|
|
@ -39,12 +39,12 @@ pub fn switch_source_header(
|
||||||
else {
|
else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
let source_file = buffer.update(cx, |buffer, _| {
|
let source_file = buffer.read_with(cx, |buffer, _| {
|
||||||
buffer.file().map(|file| file.path()).map(|path| path.to_string_lossy().to_string()).unwrap_or_else(|| "Unknown".to_string())
|
buffer.file().map(|file| file.path()).map(|path| path.to_string_lossy().to_string()).unwrap_or_else(|| "Unknown".to_string())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let switch_source_header = if let Some((client, project_id)) = upstream_client {
|
let switch_source_header = if let Some((client, project_id)) = upstream_client {
|
||||||
let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id())?;
|
let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id())?;
|
||||||
let request = proto::LspExtSwitchSourceHeader {
|
let request = proto::LspExtSwitchSourceHeader {
|
||||||
project_id,
|
project_id,
|
||||||
buffer_id: buffer_id.to_proto(),
|
buffer_id: buffer_id.to_proto(),
|
||||||
|
|
|
@ -14610,7 +14610,7 @@ impl Editor {
|
||||||
let location = match location_task {
|
let location = match location_task {
|
||||||
Some(task) => Some({
|
Some(task) => Some({
|
||||||
let target_buffer_handle = task.await.context("open local buffer")?;
|
let target_buffer_handle = task.await.context("open local buffer")?;
|
||||||
let range = target_buffer_handle.update(cx, |target_buffer, _| {
|
let range = target_buffer_handle.read_with(cx, |target_buffer, _| {
|
||||||
let target_start = target_buffer
|
let target_start = target_buffer
|
||||||
.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);
|
.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);
|
||||||
let target_end = target_buffer
|
let target_end = target_buffer
|
||||||
|
@ -14799,7 +14799,7 @@ impl Editor {
|
||||||
} else {
|
} else {
|
||||||
if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {
|
if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {
|
||||||
let (preview_item_id, preview_item_idx) =
|
let (preview_item_id, preview_item_idx) =
|
||||||
workspace.active_pane().update(cx, |pane, _| {
|
workspace.active_pane().read_with(cx, |pane, _| {
|
||||||
(pane.preview_item_id(), pane.preview_item_idx())
|
(pane.preview_item_id(), pane.preview_item_idx())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -20115,7 +20115,7 @@ impl SemanticsProvider for Entity<Project> {
|
||||||
PrepareRenameResponse::InvalidPosition => None,
|
PrepareRenameResponse::InvalidPosition => None,
|
||||||
PrepareRenameResponse::OnlyUnpreparedRenameSupported => {
|
PrepareRenameResponse::OnlyUnpreparedRenameSupported => {
|
||||||
// Fallback on using TreeSitter info to determine identifier range
|
// Fallback on using TreeSitter info to determine identifier range
|
||||||
buffer.update(cx, |buffer, _| {
|
buffer.read_with(cx, |buffer, _| {
|
||||||
let snapshot = buffer.snapshot();
|
let snapshot = buffer.snapshot();
|
||||||
let (range, kind) = snapshot.surrounding_word(position);
|
let (range, kind) = snapshot.surrounding_word(position);
|
||||||
if kind != Some(CharKind::Word) {
|
if kind != Some(CharKind::Word) {
|
||||||
|
|
|
@ -2193,7 +2193,7 @@ impl EditorElement {
|
||||||
) {
|
) {
|
||||||
let mouse_position = window.mouse_position();
|
let mouse_position = window.mouse_position();
|
||||||
let mouse_over_inline_blame = parent_bounds.contains(&mouse_position);
|
let mouse_over_inline_blame = parent_bounds.contains(&mouse_position);
|
||||||
let mouse_over_popover = self.editor.update(cx, |editor, _| {
|
let mouse_over_popover = self.editor.read_with(cx, |editor, _| {
|
||||||
editor
|
editor
|
||||||
.inline_blame_popover
|
.inline_blame_popover
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -2209,7 +2209,7 @@ impl EditorElement {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let should_draw = self.editor.update(cx, |editor, _| {
|
let should_draw = self.editor.read_with(cx, |editor, _| {
|
||||||
editor
|
editor
|
||||||
.inline_blame_popover
|
.inline_blame_popover
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -2243,7 +2243,7 @@ impl EditorElement {
|
||||||
|
|
||||||
if let Some(mut element) = maybe_element {
|
if let Some(mut element) = maybe_element {
|
||||||
let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);
|
let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);
|
||||||
let origin = self.editor.update(cx, |editor, _| {
|
let origin = self.editor.read_with(cx, |editor, _| {
|
||||||
let target_point = editor
|
let target_point = editor
|
||||||
.inline_blame_popover
|
.inline_blame_popover
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -4322,7 +4322,7 @@ impl EditorElement {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
window.with_text_style(Some(text_style), |window| {
|
window.with_text_style(Some(text_style), |window| {
|
||||||
let mut element = self.editor.update(cx, |editor, _| {
|
let mut element = self.editor.read_with(cx, |editor, _| {
|
||||||
let mouse_context_menu = editor.mouse_context_menu.as_ref()?;
|
let mouse_context_menu = editor.mouse_context_menu.as_ref()?;
|
||||||
let context_menu = mouse_context_menu.context_menu.clone();
|
let context_menu = mouse_context_menu.context_menu.clone();
|
||||||
|
|
||||||
|
|
|
@ -786,7 +786,7 @@ mod tests {
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id());
|
let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id());
|
||||||
|
|
||||||
let git_blame = cx.new(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));
|
let git_blame = cx.new(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));
|
||||||
|
|
||||||
|
@ -896,7 +896,7 @@ mod tests {
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id());
|
let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id());
|
||||||
|
|
||||||
let git_blame = cx.new(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));
|
let git_blame = cx.new(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,7 @@ pub fn show_link_definition(
|
||||||
let result = match &trigger_point {
|
let result = match &trigger_point {
|
||||||
TriggerPoint::Text(_) => {
|
TriggerPoint::Text(_) => {
|
||||||
if let Some((url_range, url)) = find_url(&buffer, buffer_position, cx.clone()) {
|
if let Some((url_range, url)) = find_url(&buffer, buffer_position, cx.clone()) {
|
||||||
this.update(cx, |_, _| {
|
this.read_with(cx, |_, _| {
|
||||||
let range = maybe!({
|
let range = maybe!({
|
||||||
let start =
|
let start =
|
||||||
snapshot.anchor_in_excerpt(excerpt_id, url_range.start)?;
|
snapshot.anchor_in_excerpt(excerpt_id, url_range.start)?;
|
||||||
|
@ -665,7 +665,7 @@ pub(crate) fn find_url(
|
||||||
) -> Option<(Range<text::Anchor>, String)> {
|
) -> Option<(Range<text::Anchor>, String)> {
|
||||||
const LIMIT: usize = 2048;
|
const LIMIT: usize = 2048;
|
||||||
|
|
||||||
let Ok(snapshot) = buffer.update(&mut cx, |buffer, _| buffer.snapshot()) else {
|
let Ok(snapshot) = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot()) else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -727,7 +727,7 @@ pub(crate) fn find_url_from_range(
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
const LIMIT: usize = 2048;
|
const LIMIT: usize = 2048;
|
||||||
|
|
||||||
let Ok(snapshot) = buffer.update(&mut cx, |buffer, _| buffer.snapshot()) else {
|
let Ok(snapshot) = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot()) else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -786,7 +786,7 @@ pub(crate) async fn find_file(
|
||||||
cx: &mut AsyncWindowContext,
|
cx: &mut AsyncWindowContext,
|
||||||
) -> Option<(Range<text::Anchor>, ResolvedPath)> {
|
) -> Option<(Range<text::Anchor>, ResolvedPath)> {
|
||||||
let project = project?;
|
let project = project?;
|
||||||
let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()).ok()?;
|
let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot()).ok()?;
|
||||||
let scope = snapshot.language_scope_at(position);
|
let scope = snapshot.language_scope_at(position);
|
||||||
let (range, candidate_file_path) = surrounding_filename(snapshot, position)?;
|
let (range, candidate_file_path) = surrounding_filename(snapshot, position)?;
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ pub fn hover_at_inlay(
|
||||||
this.hover_state.diagnostic_popover = None;
|
this.hover_state.diagnostic_popover = None;
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let language_registry = project.update(cx, |p, _| p.languages().clone())?;
|
let language_registry = project.read_with(cx, |p, _| p.languages().clone())?;
|
||||||
let blocks = vec![inlay_hover.tooltip];
|
let blocks = vec![inlay_hover.tooltip];
|
||||||
let parsed_content = parse_blocks(&blocks, &language_registry, None, cx).await;
|
let parsed_content = parse_blocks(&blocks, &language_registry, None, cx).await;
|
||||||
|
|
||||||
|
|
|
@ -639,7 +639,7 @@ impl InlayHintCache {
|
||||||
if let Some(resolved_hint_task) = resolved_hint_task {
|
if let Some(resolved_hint_task) = resolved_hint_task {
|
||||||
let mut resolved_hint =
|
let mut resolved_hint =
|
||||||
resolved_hint_task.await.context("hint resolve task")?;
|
resolved_hint_task.await.context("hint resolve task")?;
|
||||||
editor.update(cx, |editor, _| {
|
editor.read_with(cx, |editor, _| {
|
||||||
if let Some(excerpt_hints) =
|
if let Some(excerpt_hints) =
|
||||||
editor.inlay_hint_cache.hints.get(&excerpt_id)
|
editor.inlay_hint_cache.hints.get(&excerpt_id)
|
||||||
{
|
{
|
||||||
|
@ -933,7 +933,7 @@ fn fetch_and_update_hints(
|
||||||
cx: &mut Context<Editor>,
|
cx: &mut Context<Editor>,
|
||||||
) -> Task<anyhow::Result<()>> {
|
) -> Task<anyhow::Result<()>> {
|
||||||
cx.spawn(async move |editor, cx|{
|
cx.spawn(async move |editor, cx|{
|
||||||
let buffer_snapshot = excerpt_buffer.update(cx, |buffer, _| buffer.snapshot())?;
|
let buffer_snapshot = excerpt_buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
||||||
let (lsp_request_limiter, multi_buffer_snapshot) =
|
let (lsp_request_limiter, multi_buffer_snapshot) =
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
let multi_buffer_snapshot =
|
let multi_buffer_snapshot =
|
||||||
|
@ -1009,7 +1009,7 @@ fn fetch_and_update_hints(
|
||||||
.ok()
|
.ok()
|
||||||
.flatten();
|
.flatten();
|
||||||
|
|
||||||
let cached_excerpt_hints = editor.update(cx, |editor, _| {
|
let cached_excerpt_hints = editor.read_with(cx, |editor, _| {
|
||||||
editor
|
editor
|
||||||
.inlay_hint_cache
|
.inlay_hint_cache
|
||||||
.hints
|
.hints
|
||||||
|
@ -2521,7 +2521,7 @@ pub mod tests {
|
||||||
"Single buffer should produce a single excerpt with visible range"
|
"Single buffer should produce a single excerpt with visible range"
|
||||||
);
|
);
|
||||||
let (_, (excerpt_buffer, _, excerpt_visible_range)) = ranges.into_iter().next().unwrap();
|
let (_, (excerpt_buffer, _, excerpt_visible_range)) = ranges.into_iter().next().unwrap();
|
||||||
excerpt_buffer.update(cx, |buffer, _| {
|
excerpt_buffer.read_with(cx, |buffer, _| {
|
||||||
let snapshot = buffer.snapshot();
|
let snapshot = buffer.snapshot();
|
||||||
let start = buffer
|
let start = buffer
|
||||||
.anchor_before(excerpt_visible_range.start)
|
.anchor_before(excerpt_visible_range.start)
|
||||||
|
|
|
@ -841,7 +841,7 @@ impl Item for Editor {
|
||||||
// so that language servers or other downstream listeners of save events get notified.
|
// so that language servers or other downstream listeners of save events get notified.
|
||||||
let (dirty_buffers, clean_buffers) = buffers.into_iter().partition(|buffer| {
|
let (dirty_buffers, clean_buffers) = buffers.into_iter().partition(|buffer| {
|
||||||
buffer
|
buffer
|
||||||
.update(cx, |buffer, _| buffer.is_dirty() || buffer.has_conflict())
|
.read_with(cx, |buffer, _| buffer.is_dirty() || buffer.has_conflict())
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1089,7 +1089,7 @@ impl SerializableItem for Editor {
|
||||||
let project = project.clone();
|
let project = project.clone();
|
||||||
async move |cx| {
|
async move |cx| {
|
||||||
let language_registry =
|
let language_registry =
|
||||||
project.update(cx, |project, _| project.languages().clone())?;
|
project.read_with(cx, |project, _| project.languages().clone())?;
|
||||||
|
|
||||||
let language = if let Some(language_name) = language {
|
let language = if let Some(language_name) = language {
|
||||||
// We don't fail here, because we'd rather not set the language if the name changed
|
// We don't fail here, because we'd rather not set the language if the name changed
|
||||||
|
@ -2032,7 +2032,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
let project = Project::test(fs.clone(), [path!("/file.rs").as_ref()], cx).await;
|
let project = Project::test(fs.clone(), [path!("/file.rs").as_ref()], cx).await;
|
||||||
// Add Rust to the language, so that we can restore the language of the buffer
|
// Add Rust to the language, so that we can restore the language of the buffer
|
||||||
project.update(cx, |project, _| project.languages().add(rust_language()));
|
project.read_with(cx, |project, _| project.languages().add(rust_language()));
|
||||||
|
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
|
|
|
@ -81,7 +81,7 @@ async fn lsp_task_context(
|
||||||
cx: &mut AsyncApp,
|
cx: &mut AsyncApp,
|
||||||
) -> Option<TaskContext> {
|
) -> Option<TaskContext> {
|
||||||
let worktree_store = project
|
let worktree_store = project
|
||||||
.update(cx, |project, _| project.worktree_store())
|
.read_with(cx, |project, _| project.worktree_store())
|
||||||
.ok()?;
|
.ok()?;
|
||||||
|
|
||||||
let worktree_abs_path = cx
|
let worktree_abs_path = cx
|
||||||
|
|
|
@ -73,7 +73,7 @@ pub fn go_to_parent_module(
|
||||||
};
|
};
|
||||||
|
|
||||||
let location_links = if let Some((client, project_id)) = upstream_client {
|
let location_links = if let Some((client, project_id)) = upstream_client {
|
||||||
let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id())?;
|
let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id())?;
|
||||||
|
|
||||||
let request = proto::LspExtGoToParentModule {
|
let request = proto::LspExtGoToParentModule {
|
||||||
project_id,
|
project_id,
|
||||||
|
@ -95,7 +95,7 @@ pub fn go_to_parent_module(
|
||||||
.collect::<anyhow::Result<_>>()
|
.collect::<anyhow::Result<_>>()
|
||||||
.context("go to parent module via collab")?
|
.context("go to parent module via collab")?
|
||||||
} else {
|
} else {
|
||||||
let buffer_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot())?;
|
let buffer_snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
||||||
let position = trigger_anchor.text_anchor.to_point_utf16(&buffer_snapshot);
|
let position = trigger_anchor.text_anchor.to_point_utf16(&buffer_snapshot);
|
||||||
project
|
project
|
||||||
.update(cx, |project, cx| {
|
.update(cx, |project, cx| {
|
||||||
|
@ -173,7 +173,7 @@ pub fn expand_macro_recursively(
|
||||||
expansion: response.expansion,
|
expansion: response.expansion,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let buffer_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot())?;
|
let buffer_snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
||||||
let position = trigger_anchor.text_anchor.to_point_utf16(&buffer_snapshot);
|
let position = trigger_anchor.text_anchor.to_point_utf16(&buffer_snapshot);
|
||||||
project
|
project
|
||||||
.update(cx, |project, cx| {
|
.update(cx, |project, cx| {
|
||||||
|
@ -249,7 +249,7 @@ pub fn open_docs(editor: &mut Editor, _: &OpenDocs, window: &mut Window, cx: &mu
|
||||||
};
|
};
|
||||||
|
|
||||||
let docs_urls = if let Some((client, project_id)) = upstream_client {
|
let docs_urls = if let Some((client, project_id)) = upstream_client {
|
||||||
let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id())?;
|
let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id())?;
|
||||||
let request = proto::LspExtOpenDocs {
|
let request = proto::LspExtOpenDocs {
|
||||||
project_id,
|
project_id,
|
||||||
buffer_id: buffer_id.to_proto(),
|
buffer_id: buffer_id.to_proto(),
|
||||||
|
@ -264,7 +264,7 @@ pub fn open_docs(editor: &mut Editor, _: &OpenDocs, window: &mut Window, cx: &mu
|
||||||
local: response.local,
|
local: response.local,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let buffer_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot())?;
|
let buffer_snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
||||||
let position = trigger_anchor.text_anchor.to_point_utf16(&buffer_snapshot);
|
let position = trigger_anchor.text_anchor.to_point_utf16(&buffer_snapshot);
|
||||||
project
|
project
|
||||||
.update(cx, |project, cx| {
|
.update(cx, |project, cx| {
|
||||||
|
|
|
@ -644,7 +644,7 @@ pub fn wait_for_lang_server(
|
||||||
let (mut tx, mut rx) = mpsc::channel(1);
|
let (mut tx, mut rx) = mpsc::channel(1);
|
||||||
|
|
||||||
let lsp_store = project
|
let lsp_store = project
|
||||||
.update(cx, |project, _| project.lsp_store())
|
.read_with(cx, |project, _| project.lsp_store())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let has_lang_server = buffer
|
let has_lang_server = buffer
|
||||||
|
|
|
@ -447,9 +447,11 @@ impl ExtensionsPage {
|
||||||
|
|
||||||
let extension_store = ExtensionStore::global(cx);
|
let extension_store = ExtensionStore::global(cx);
|
||||||
|
|
||||||
let dev_extensions = extension_store.update(cx, |store, _| {
|
let dev_extensions = extension_store
|
||||||
store.dev_extensions().cloned().collect::<Vec<_>>()
|
.read(cx)
|
||||||
});
|
.dev_extensions()
|
||||||
|
.cloned()
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let remote_extensions = extension_store.update(cx, |store, cx| {
|
let remote_extensions = extension_store.update(cx, |store, cx| {
|
||||||
store.fetch_extensions(search.as_deref(), provides_filter.as_ref(), cx)
|
store.fetch_extensions(search.as_deref(), provides_filter.as_ref(), cx)
|
||||||
|
|
|
@ -1036,7 +1036,7 @@ impl FileFinderDelegate {
|
||||||
) -> Task<()> {
|
) -> Task<()> {
|
||||||
cx.spawn_in(window, async move |picker, cx| {
|
cx.spawn_in(window, async move |picker, cx| {
|
||||||
let Some(project) = picker
|
let Some(project) = picker
|
||||||
.update(cx, |picker, _| picker.delegate.project.clone())
|
.read_with(cx, |picker, _| picker.delegate.project.clone())
|
||||||
.log_err()
|
.log_err()
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -360,7 +360,7 @@ impl PickerDelegate for BranchListDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
let current_branch = self.repo.as_ref().map(|repo| {
|
let current_branch = self.repo.as_ref().map(|repo| {
|
||||||
repo.update(cx, |repo, _| {
|
repo.read_with(cx, |repo, _| {
|
||||||
repo.branch.as_ref().map(|branch| branch.ref_name.clone())
|
repo.branch.as_ref().map(|branch| branch.ref_name.clone())
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -4851,7 +4851,7 @@ mod tests {
|
||||||
|
|
||||||
cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
|
|
||||||
let app_state = workspace.update(cx, |workspace, _| workspace.app_state().clone());
|
let app_state = workspace.read_with(cx, |workspace, _| workspace.app_state().clone());
|
||||||
let panel = cx.new_window_entity(|window, cx| {
|
let panel = cx.new_window_entity(|window, cx| {
|
||||||
GitPanel::new(workspace.clone(), project.clone(), app_state, window, cx)
|
GitPanel::new(workspace.clone(), project.clone(), app_state, window, cx)
|
||||||
});
|
});
|
||||||
|
@ -4862,7 +4862,7 @@ mod tests {
|
||||||
cx.executor().advance_clock(2 * UPDATE_DEBOUNCE);
|
cx.executor().advance_clock(2 * UPDATE_DEBOUNCE);
|
||||||
handle.await;
|
handle.await;
|
||||||
|
|
||||||
let entries = panel.update(cx, |panel, _| panel.entries.clone());
|
let entries = panel.read_with(cx, |panel, _| panel.entries.clone());
|
||||||
pretty_assertions::assert_eq!(
|
pretty_assertions::assert_eq!(
|
||||||
entries,
|
entries,
|
||||||
[
|
[
|
||||||
|
@ -4937,7 +4937,7 @@ mod tests {
|
||||||
});
|
});
|
||||||
cx.executor().advance_clock(2 * UPDATE_DEBOUNCE);
|
cx.executor().advance_clock(2 * UPDATE_DEBOUNCE);
|
||||||
handle.await;
|
handle.await;
|
||||||
let entries = panel.update(cx, |panel, _| panel.entries.clone());
|
let entries = panel.read_with(cx, |panel, _| panel.entries.clone());
|
||||||
pretty_assertions::assert_eq!(
|
pretty_assertions::assert_eq!(
|
||||||
entries,
|
entries,
|
||||||
[
|
[
|
||||||
|
|
|
@ -144,7 +144,7 @@ impl PickerDelegate for PickerPromptDelegate {
|
||||||
cx: &mut Context<Picker<Self>>,
|
cx: &mut Context<Picker<Self>>,
|
||||||
) -> Task<()> {
|
) -> Task<()> {
|
||||||
cx.spawn_in(window, async move |picker, cx| {
|
cx.spawn_in(window, async move |picker, cx| {
|
||||||
let candidates = picker.update(cx, |picker, _| {
|
let candidates = picker.read_with(cx, |picker, _| {
|
||||||
picker
|
picker
|
||||||
.delegate
|
.delegate
|
||||||
.all_options
|
.all_options
|
||||||
|
|
|
@ -1394,7 +1394,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
|
|
||||||
let editor = diff.update(cx, |diff, _| diff.editor.clone());
|
let editor = diff.read_with(cx, |diff, _| diff.editor.clone());
|
||||||
assert_state_with_diff(
|
assert_state_with_diff(
|
||||||
&editor,
|
&editor,
|
||||||
cx,
|
cx,
|
||||||
|
@ -1526,7 +1526,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
|
|
||||||
let diff_editor = diff.update(cx, |diff, _| diff.editor.clone());
|
let diff_editor = diff.read_with(cx, |diff, _| diff.editor.clone());
|
||||||
|
|
||||||
assert_state_with_diff(
|
assert_state_with_diff(
|
||||||
&diff_editor,
|
&diff_editor,
|
||||||
|
@ -1642,7 +1642,7 @@ mod tests {
|
||||||
workspace.active_item_as::<ProjectDiff>(cx).unwrap()
|
workspace.active_item_as::<ProjectDiff>(cx).unwrap()
|
||||||
});
|
});
|
||||||
cx.focus(&item);
|
cx.focus(&item);
|
||||||
let editor = item.update(cx, |item, _| item.editor.clone());
|
let editor = item.read_with(cx, |item, _| item.editor.clone());
|
||||||
|
|
||||||
let mut cx = EditorTestContext::for_editor_in(editor, cx).await;
|
let mut cx = EditorTestContext::for_editor_in(editor, cx).await;
|
||||||
|
|
||||||
|
@ -1756,7 +1756,7 @@ mod tests {
|
||||||
workspace.active_item_as::<ProjectDiff>(cx).unwrap()
|
workspace.active_item_as::<ProjectDiff>(cx).unwrap()
|
||||||
});
|
});
|
||||||
cx.focus(&item);
|
cx.focus(&item);
|
||||||
let editor = item.update(cx, |item, _| item.editor.clone());
|
let editor = item.read_with(cx, |item, _| item.editor.clone());
|
||||||
|
|
||||||
let mut cx = EditorTestContext::for_editor_in(editor, cx).await;
|
let mut cx = EditorTestContext::for_editor_in(editor, cx).await;
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ mod tests {
|
||||||
.unindent();
|
.unindent();
|
||||||
|
|
||||||
let buffer = cx.new(|cx| language::Buffer::local(text, cx).with_language(language, cx));
|
let buffer = cx.new(|cx| language::Buffer::local(text, cx).with_language(language, cx));
|
||||||
let outline = buffer.update(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());
|
let outline = buffer.read_with(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
outline
|
outline
|
||||||
.items
|
.items
|
||||||
|
|
|
@ -596,7 +596,7 @@ mod tests {
|
||||||
.unindent();
|
.unindent();
|
||||||
|
|
||||||
let buffer = cx.new(|cx| language::Buffer::local(text, cx).with_language(language, cx));
|
let buffer = cx.new(|cx| language::Buffer::local(text, cx).with_language(language, cx));
|
||||||
let outline = buffer.update(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());
|
let outline = buffer.read_with(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
outline
|
outline
|
||||||
.items
|
.items
|
||||||
|
|
|
@ -1575,7 +1575,7 @@ impl MultiBuffer {
|
||||||
context_line_count: u32,
|
context_line_count: u32,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> (Vec<Range<Anchor>>, bool) {
|
) -> (Vec<Range<Anchor>>, bool) {
|
||||||
let buffer_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot());
|
let buffer_snapshot = buffer.read(cx).snapshot();
|
||||||
let excerpt_ranges = build_excerpt_ranges(ranges, context_line_count, &buffer_snapshot);
|
let excerpt_ranges = build_excerpt_ranges(ranges, context_line_count, &buffer_snapshot);
|
||||||
|
|
||||||
let (new, counts) = Self::merge_excerpt_ranges(&excerpt_ranges);
|
let (new, counts) = Self::merge_excerpt_ranges(&excerpt_ranges);
|
||||||
|
|
|
@ -532,7 +532,7 @@ mod tests {
|
||||||
outline_view: &Entity<Picker<OutlineViewDelegate>>,
|
outline_view: &Entity<Picker<OutlineViewDelegate>>,
|
||||||
cx: &mut VisualTestContext,
|
cx: &mut VisualTestContext,
|
||||||
) -> Vec<String> {
|
) -> Vec<String> {
|
||||||
outline_view.update(cx, |outline_view, _| {
|
outline_view.read_with(cx, |outline_view, _| {
|
||||||
let items = &outline_view.delegate.outline.items;
|
let items = &outline_view.delegate.outline.items;
|
||||||
outline_view
|
outline_view
|
||||||
.delegate
|
.delegate
|
||||||
|
|
|
@ -865,7 +865,7 @@ impl OutlinePanel {
|
||||||
fn serialize(&mut self, cx: &mut Context<Self>) {
|
fn serialize(&mut self, cx: &mut Context<Self>) {
|
||||||
let Some(serialization_key) = self
|
let Some(serialization_key) = self
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |workspace, _| {
|
.read_with(cx, |workspace, _| {
|
||||||
OutlinePanel::serialization_key(workspace)
|
OutlinePanel::serialization_key(workspace)
|
||||||
})
|
})
|
||||||
.ok()
|
.ok()
|
||||||
|
@ -5642,7 +5642,7 @@ mod tests {
|
||||||
.advance_clock(UPDATE_DEBOUNCE + Duration::from_millis(100));
|
.advance_clock(UPDATE_DEBOUNCE + Duration::from_millis(100));
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
|
|
||||||
let active_editor = outline_panel.update(cx, |outline_panel, _| {
|
let active_editor = outline_panel.read_with(cx, |outline_panel, _| {
|
||||||
outline_panel
|
outline_panel
|
||||||
.active_editor()
|
.active_editor()
|
||||||
.expect("should have an active editor open")
|
.expect("should have an active editor open")
|
||||||
|
@ -5737,7 +5737,7 @@ mod tests {
|
||||||
cx.executor()
|
cx.executor()
|
||||||
.advance_clock(UPDATE_DEBOUNCE + Duration::from_millis(100));
|
.advance_clock(UPDATE_DEBOUNCE + Duration::from_millis(100));
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
let new_active_editor = outline_panel.update(cx, |outline_panel, _| {
|
let new_active_editor = outline_panel.read_with(cx, |outline_panel, _| {
|
||||||
outline_panel
|
outline_panel
|
||||||
.active_editor()
|
.active_editor()
|
||||||
.expect("should have an active editor open")
|
.expect("should have an active editor open")
|
||||||
|
|
|
@ -1340,7 +1340,7 @@ impl BufferStore {
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::BufferSaved> {
|
) -> Result<proto::BufferSaved> {
|
||||||
let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
|
let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
|
||||||
let (buffer, project_id) = this.update(&mut cx, |this, _| {
|
let (buffer, project_id) = this.read_with(&mut cx, |this, _| {
|
||||||
anyhow::Ok((
|
anyhow::Ok((
|
||||||
this.get_existing(buffer_id)?,
|
this.get_existing(buffer_id)?,
|
||||||
this.downstream_client
|
this.downstream_client
|
||||||
|
@ -1354,7 +1354,7 @@ impl BufferStore {
|
||||||
buffer.wait_for_version(deserialize_version(&envelope.payload.version))
|
buffer.wait_for_version(deserialize_version(&envelope.payload.version))
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
let buffer_id = buffer.update(&mut cx, |buffer, _| buffer.remote_id())?;
|
let buffer_id = buffer.read_with(&mut cx, |buffer, _| buffer.remote_id())?;
|
||||||
|
|
||||||
if let Some(new_path) = envelope.payload.new_path {
|
if let Some(new_path) = envelope.payload.new_path {
|
||||||
let new_path = ProjectPath::from_proto(new_path);
|
let new_path = ProjectPath::from_proto(new_path);
|
||||||
|
@ -1367,7 +1367,7 @@ impl BufferStore {
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.update(&mut cx, |buffer, _| proto::BufferSaved {
|
buffer.read_with(&mut cx, |buffer, _| proto::BufferSaved {
|
||||||
project_id,
|
project_id,
|
||||||
buffer_id: buffer_id.into(),
|
buffer_id: buffer_id.into(),
|
||||||
version: serialize_version(buffer.saved_version()),
|
version: serialize_version(buffer.saved_version()),
|
||||||
|
@ -1524,7 +1524,7 @@ impl BufferStore {
|
||||||
};
|
};
|
||||||
|
|
||||||
cx.spawn(async move |this, cx| {
|
cx.spawn(async move |this, cx| {
|
||||||
let Some(buffer) = this.update(cx, |this, _| this.get(buffer_id))? else {
|
let Some(buffer) = this.read_with(cx, |this, _| this.get(buffer_id))? else {
|
||||||
return anyhow::Ok(());
|
return anyhow::Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ impl BreakpointStore {
|
||||||
message: TypedEnvelope<proto::ToggleBreakpoint>,
|
message: TypedEnvelope<proto::ToggleBreakpoint>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::Ack> {
|
) -> Result<proto::Ack> {
|
||||||
let breakpoints = this.update(&mut cx, |this, _| this.breakpoint_store())?;
|
let breakpoints = this.read_with(&mut cx, |this, _| this.breakpoint_store())?;
|
||||||
let path = this
|
let path = this
|
||||||
.update(&mut cx, |this, cx| {
|
.update(&mut cx, |this, cx| {
|
||||||
this.project_path_for_absolute_path(message.payload.path.as_ref(), cx)
|
this.project_path_for_absolute_path(message.payload.path.as_ref(), cx)
|
||||||
|
@ -803,7 +803,7 @@ impl BreakpointStore {
|
||||||
log::error!("Todo: Serialized breakpoints which do not have buffer (yet)");
|
log::error!("Todo: Serialized breakpoints which do not have buffer (yet)");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot())?;
|
let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
||||||
|
|
||||||
let mut breakpoints_for_file =
|
let mut breakpoints_for_file =
|
||||||
this.update(cx, |_, cx| BreakpointsInFile::new(buffer, cx))?;
|
this.update(cx, |_, cx| BreakpointsInFile::new(buffer, cx))?;
|
||||||
|
|
|
@ -232,7 +232,7 @@ impl DapStore {
|
||||||
cx.spawn(async move |_, cx| {
|
cx.spawn(async move |_, cx| {
|
||||||
let response = request.await?;
|
let response = request.await?;
|
||||||
let binary = DebugAdapterBinary::from_proto(response)?;
|
let binary = DebugAdapterBinary::from_proto(response)?;
|
||||||
let mut ssh_command = ssh_client.update(cx, |ssh, _| {
|
let mut ssh_command = ssh_client.read_with(cx, |ssh, _| {
|
||||||
anyhow::Ok(SshCommand {
|
anyhow::Ok(SshCommand {
|
||||||
arguments: ssh.ssh_args().context("SSH arguments not found")?,
|
arguments: ssh.ssh_args().context("SSH arguments not found")?,
|
||||||
})
|
})
|
||||||
|
@ -609,7 +609,7 @@ impl DapStore {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
VariableLookupKind::Expression => {
|
VariableLookupKind::Expression => {
|
||||||
let Ok(eval_task) = session.update(cx, |session, _| {
|
let Ok(eval_task) = session.read_with(cx, |session, _| {
|
||||||
session.mode.request_dap(EvaluateCommand {
|
session.mode.request_dap(EvaluateCommand {
|
||||||
expression: inline_value_location.variable_name.clone(),
|
expression: inline_value_location.variable_name.clone(),
|
||||||
frame_id: Some(stack_frame_id),
|
frame_id: Some(stack_frame_id),
|
||||||
|
@ -752,7 +752,7 @@ impl DapStore {
|
||||||
let this = this.clone();
|
let this = this.clone();
|
||||||
async move |cx| {
|
async move |cx| {
|
||||||
while let Some(message) = rx.next().await {
|
while let Some(message) = rx.next().await {
|
||||||
this.update(cx, |this, _| {
|
this.read_with(cx, |this, _| {
|
||||||
if let Some((downstream, project_id)) = this.downstream_client.clone() {
|
if let Some((downstream, project_id)) = this.downstream_client.clone() {
|
||||||
downstream
|
downstream
|
||||||
.send(proto::LogToDebugConsole {
|
.send(proto::LogToDebugConsole {
|
||||||
|
|
|
@ -407,7 +407,7 @@ impl LocalMode {
|
||||||
let configuration_sequence = cx.spawn({
|
let configuration_sequence = cx.spawn({
|
||||||
async move |cx| {
|
async move |cx| {
|
||||||
let breakpoint_store =
|
let breakpoint_store =
|
||||||
dap_store.update(cx, |dap_store, _| dap_store.breakpoint_store().clone())?;
|
dap_store.read_with(cx, |dap_store, _| dap_store.breakpoint_store().clone())?;
|
||||||
initialized_rx.await?;
|
initialized_rx.await?;
|
||||||
let errors_by_path = cx
|
let errors_by_path = cx
|
||||||
.update(|cx| this.send_source_breakpoints(false, &breakpoint_store, cx))?
|
.update(|cx| this.send_source_breakpoints(false, &breakpoint_store, cx))?
|
||||||
|
|
|
@ -2179,7 +2179,7 @@ impl GitStore {
|
||||||
id: RepositoryId,
|
id: RepositoryId,
|
||||||
cx: &mut AsyncApp,
|
cx: &mut AsyncApp,
|
||||||
) -> Result<Entity<Repository>> {
|
) -> Result<Entity<Repository>> {
|
||||||
this.update(cx, |this, _| {
|
this.read_with(cx, |this, _| {
|
||||||
this.repositories
|
this.repositories
|
||||||
.get(&id)
|
.get(&id)
|
||||||
.context("missing repository handle")
|
.context("missing repository handle")
|
||||||
|
@ -4022,7 +4022,7 @@ impl Repository {
|
||||||
bail!("not a local repository")
|
bail!("not a local repository")
|
||||||
};
|
};
|
||||||
let (snapshot, events) = this
|
let (snapshot, events) = this
|
||||||
.update(&mut cx, |this, _| {
|
.read_with(&mut cx, |this, _| {
|
||||||
compute_snapshot(
|
compute_snapshot(
|
||||||
this.id,
|
this.id,
|
||||||
this.work_directory_abs_path.clone(),
|
this.work_directory_abs_path.clone(),
|
||||||
|
|
|
@ -504,7 +504,8 @@ mod tests {
|
||||||
events_tx.send(event.clone()).ok();
|
events_tx.send(event.clone()).ok();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
let conflicts_snapshot = conflict_set.update(cx, |conflict_set, _| conflict_set.snapshot());
|
let conflicts_snapshot =
|
||||||
|
conflict_set.read_with(cx, |conflict_set, _| conflict_set.snapshot());
|
||||||
assert!(conflicts_snapshot.conflicts.is_empty());
|
assert!(conflicts_snapshot.conflicts.is_empty());
|
||||||
|
|
||||||
buffer.update(cx, |buffer, cx| {
|
buffer.update(cx, |buffer, cx| {
|
||||||
|
@ -543,7 +544,7 @@ mod tests {
|
||||||
assert_eq!(update.old_range, 0..0);
|
assert_eq!(update.old_range, 0..0);
|
||||||
assert_eq!(update.new_range, 0..1);
|
assert_eq!(update.new_range, 0..1);
|
||||||
|
|
||||||
let conflict = conflict_set.update(cx, |conflict_set, _| {
|
let conflict = conflict_set.read_with(cx, |conflict_set, _| {
|
||||||
conflict_set.snapshot().conflicts[0].clone()
|
conflict_set.snapshot().conflicts[0].clone()
|
||||||
});
|
});
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
|
|
|
@ -313,7 +313,7 @@ impl LspCommand for PrepareRename {
|
||||||
_: LanguageServerId,
|
_: LanguageServerId,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<PrepareRenameResponse> {
|
) -> Result<PrepareRenameResponse> {
|
||||||
buffer.update(&mut cx, |buffer, _| match message {
|
buffer.read_with(&mut cx, |buffer, _| match message {
|
||||||
Some(lsp::PrepareRenameResponse::Range(range))
|
Some(lsp::PrepareRenameResponse::Range(range))
|
||||||
| Some(lsp::PrepareRenameResponse::RangeWithPlaceholder { range, .. }) => {
|
| Some(lsp::PrepareRenameResponse::RangeWithPlaceholder { range, .. }) => {
|
||||||
let Range { start, end } = range_from_lsp(range);
|
let Range { start, end } = range_from_lsp(range);
|
||||||
|
@ -365,7 +365,7 @@ impl LspCommand for PrepareRename {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ impl LspCommand for PerformRename {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
new_name: message.new_name,
|
new_name: message.new_name,
|
||||||
push_to_history: false,
|
push_to_history: false,
|
||||||
})
|
})
|
||||||
|
@ -625,7 +625,7 @@ impl LspCommand for GetDefinition {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,7 +724,7 @@ impl LspCommand for GetDeclaration {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ impl LspCommand for GetImplementation {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -915,7 +915,7 @@ impl LspCommand for GetTypeDefinition {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1296,7 +1296,7 @@ impl LspCommand for GetReferences {
|
||||||
|
|
||||||
target_buffer_handle
|
target_buffer_handle
|
||||||
.clone()
|
.clone()
|
||||||
.update(&mut cx, |target_buffer, _| {
|
.read_with(&mut cx, |target_buffer, _| {
|
||||||
let target_start = target_buffer
|
let target_start = target_buffer
|
||||||
.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);
|
.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);
|
||||||
let target_end = target_buffer
|
let target_end = target_buffer
|
||||||
|
@ -1340,7 +1340,7 @@ impl LspCommand for GetReferences {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1449,7 +1449,7 @@ impl LspCommand for GetDocumentHighlights {
|
||||||
_: LanguageServerId,
|
_: LanguageServerId,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<Vec<DocumentHighlight>> {
|
) -> Result<Vec<DocumentHighlight>> {
|
||||||
buffer.update(&mut cx, |buffer, _| {
|
buffer.read_with(&mut cx, |buffer, _| {
|
||||||
let mut lsp_highlights = lsp_highlights.unwrap_or_default();
|
let mut lsp_highlights = lsp_highlights.unwrap_or_default();
|
||||||
lsp_highlights.sort_unstable_by_key(|h| (h.range.start, Reverse(h.range.end)));
|
lsp_highlights.sort_unstable_by_key(|h| (h.range.start, Reverse(h.range.end)));
|
||||||
lsp_highlights
|
lsp_highlights
|
||||||
|
@ -1497,7 +1497,7 @@ impl LspCommand for GetDocumentHighlights {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1822,7 +1822,7 @@ impl LspCommand for GetSignatureHelp {
|
||||||
})?
|
})?
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("waiting for version for buffer {}", buffer.entity_id()))?;
|
.with_context(|| format!("waiting for version for buffer {}", buffer.entity_id()))?;
|
||||||
let buffer_snapshot = buffer.update(&mut cx, |buffer, _| buffer.snapshot())?;
|
let buffer_snapshot = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot())?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: payload
|
position: payload
|
||||||
.position
|
.position
|
||||||
|
@ -1906,7 +1906,7 @@ impl LspCommand for GetHover {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
let (language, range) = buffer.update(&mut cx, |buffer, _| {
|
let (language, range) = buffer.read_with(&mut cx, |buffer, _| {
|
||||||
(
|
(
|
||||||
buffer.language().cloned(),
|
buffer.language().cloned(),
|
||||||
hover.range.map(|range| {
|
hover.range.map(|range| {
|
||||||
|
@ -1992,7 +1992,7 @@ impl LspCommand for GetHover {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2066,7 +2066,7 @@ impl LspCommand for GetHover {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
let language = buffer.update(&mut cx, |buffer, _| buffer.language().cloned())?;
|
let language = buffer.read_with(&mut cx, |buffer, _| buffer.language().cloned())?;
|
||||||
let range = if let (Some(start), Some(end)) = (message.start, message.end) {
|
let range = if let (Some(start), Some(end)) = (message.start, message.end) {
|
||||||
language::proto::deserialize_anchor(start)
|
language::proto::deserialize_anchor(start)
|
||||||
.and_then(|start| language::proto::deserialize_anchor(end).map(|end| start..end))
|
.and_then(|start| language::proto::deserialize_anchor(end).map(|end| start..end))
|
||||||
|
@ -2141,7 +2141,7 @@ impl LspCommand for GetCompletions {
|
||||||
};
|
};
|
||||||
|
|
||||||
let language_server_adapter = lsp_store
|
let language_server_adapter = lsp_store
|
||||||
.update(&mut cx, |lsp_store, _| {
|
.read_with(&mut cx, |lsp_store, _| {
|
||||||
lsp_store.language_server_adapter_for_id(server_id)
|
lsp_store.language_server_adapter_for_id(server_id)
|
||||||
})?
|
})?
|
||||||
.with_context(|| format!("no language server with id {server_id}"))?;
|
.with_context(|| format!("no language server with id {server_id}"))?;
|
||||||
|
@ -2317,7 +2317,7 @@ impl LspCommand for GetCompletions {
|
||||||
.position
|
.position
|
||||||
.and_then(language::proto::deserialize_anchor)
|
.and_then(language::proto::deserialize_anchor)
|
||||||
.map(|p| {
|
.map(|p| {
|
||||||
buffer.update(&mut cx, |buffer, _| {
|
buffer.read_with(&mut cx, |buffer, _| {
|
||||||
buffer.clip_point_utf16(Unclipped(p.to_point_utf16(buffer)), Bias::Left)
|
buffer.clip_point_utf16(Unclipped(p.to_point_utf16(buffer)), Bias::Left)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -2773,7 +2773,7 @@ impl LspCommand for OnTypeFormatting {
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
trigger: message.trigger.clone(),
|
trigger: message.trigger.clone(),
|
||||||
options,
|
options,
|
||||||
push_to_history: false,
|
push_to_history: false,
|
||||||
|
@ -2826,7 +2826,7 @@ impl InlayHints {
|
||||||
_ => None,
|
_ => None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let position = buffer_handle.update(cx, |buffer, _| {
|
let position = buffer_handle.read_with(cx, |buffer, _| {
|
||||||
let position = buffer.clip_point_utf16(point_from_lsp(lsp_hint.position), Bias::Left);
|
let position = buffer.clip_point_utf16(point_from_lsp(lsp_hint.position), Bias::Left);
|
||||||
if kind == Some(InlayHintKind::Parameter) {
|
if kind == Some(InlayHintKind::Parameter) {
|
||||||
buffer.anchor_before(position)
|
buffer.anchor_before(position)
|
||||||
|
@ -3387,7 +3387,7 @@ impl LspCommand for GetCodeLens {
|
||||||
server_id: LanguageServerId,
|
server_id: LanguageServerId,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> anyhow::Result<Vec<CodeAction>> {
|
) -> anyhow::Result<Vec<CodeAction>> {
|
||||||
let snapshot = buffer.update(&mut cx, |buffer, _| buffer.snapshot())?;
|
let snapshot = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot())?;
|
||||||
let language_server = cx.update(|cx| {
|
let language_server = cx.update(|cx| {
|
||||||
lsp_store
|
lsp_store
|
||||||
.read(cx)
|
.read(cx)
|
||||||
|
|
|
@ -535,8 +535,8 @@ impl LocalLspStore {
|
||||||
let this = this.clone();
|
let this = this.clone();
|
||||||
let mut cx = cx.clone();
|
let mut cx = cx.clone();
|
||||||
async move {
|
async move {
|
||||||
let Some(server) =
|
let Some(server) = this
|
||||||
this.update(&mut cx, |this, _| this.language_server_for_id(server_id))?
|
.read_with(&mut cx, |this, _| this.language_server_for_id(server_id))?
|
||||||
else {
|
else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
@ -600,7 +600,7 @@ impl LocalLspStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"textDocument/rangeFormatting" => {
|
"textDocument/rangeFormatting" => {
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
if let Some(server) = this.language_server_for_id(server_id)
|
if let Some(server) = this.language_server_for_id(server_id)
|
||||||
{
|
{
|
||||||
let options = reg
|
let options = reg
|
||||||
|
@ -626,7 +626,7 @@ impl LocalLspStore {
|
||||||
})??;
|
})??;
|
||||||
}
|
}
|
||||||
"textDocument/onTypeFormatting" => {
|
"textDocument/onTypeFormatting" => {
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
if let Some(server) = this.language_server_for_id(server_id)
|
if let Some(server) = this.language_server_for_id(server_id)
|
||||||
{
|
{
|
||||||
let options = reg
|
let options = reg
|
||||||
|
@ -651,7 +651,7 @@ impl LocalLspStore {
|
||||||
})??;
|
})??;
|
||||||
}
|
}
|
||||||
"textDocument/formatting" => {
|
"textDocument/formatting" => {
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
if let Some(server) = this.language_server_for_id(server_id)
|
if let Some(server) = this.language_server_for_id(server_id)
|
||||||
{
|
{
|
||||||
let options = reg
|
let options = reg
|
||||||
|
@ -680,7 +680,7 @@ impl LocalLspStore {
|
||||||
// Ignore payload since we notify clients of setting changes unconditionally, relying on them pulling the latest settings.
|
// Ignore payload since we notify clients of setting changes unconditionally, relying on them pulling the latest settings.
|
||||||
}
|
}
|
||||||
"textDocument/rename" => {
|
"textDocument/rename" => {
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
if let Some(server) = this.language_server_for_id(server_id)
|
if let Some(server) = this.language_server_for_id(server_id)
|
||||||
{
|
{
|
||||||
let options = reg
|
let options = reg
|
||||||
|
@ -734,7 +734,7 @@ impl LocalLspStore {
|
||||||
// Ignore payload since we notify clients of setting changes unconditionally, relying on them pulling the latest settings.
|
// Ignore payload since we notify clients of setting changes unconditionally, relying on them pulling the latest settings.
|
||||||
}
|
}
|
||||||
"textDocument/rename" => {
|
"textDocument/rename" => {
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
if let Some(server) = this.language_server_for_id(server_id)
|
if let Some(server) = this.language_server_for_id(server_id)
|
||||||
{
|
{
|
||||||
server.update_capabilities(|capabilities| {
|
server.update_capabilities(|capabilities| {
|
||||||
|
@ -744,7 +744,7 @@ impl LocalLspStore {
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
"textDocument/rangeFormatting" => {
|
"textDocument/rangeFormatting" => {
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
if let Some(server) = this.language_server_for_id(server_id)
|
if let Some(server) = this.language_server_for_id(server_id)
|
||||||
{
|
{
|
||||||
server.update_capabilities(|capabilities| {
|
server.update_capabilities(|capabilities| {
|
||||||
|
@ -755,7 +755,7 @@ impl LocalLspStore {
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
"textDocument/onTypeFormatting" => {
|
"textDocument/onTypeFormatting" => {
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
if let Some(server) = this.language_server_for_id(server_id)
|
if let Some(server) = this.language_server_for_id(server_id)
|
||||||
{
|
{
|
||||||
server.update_capabilities(|capabilities| {
|
server.update_capabilities(|capabilities| {
|
||||||
|
@ -766,7 +766,7 @@ impl LocalLspStore {
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
"textDocument/formatting" => {
|
"textDocument/formatting" => {
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
if let Some(server) = this.language_server_for_id(server_id)
|
if let Some(server) = this.language_server_for_id(server_id)
|
||||||
{
|
{
|
||||||
server.update_capabilities(|capabilities| {
|
server.update_capabilities(|capabilities| {
|
||||||
|
@ -1954,7 +1954,7 @@ impl LocalLspStore {
|
||||||
} else if matches!(range_formatting_provider, Some(p) if *p != OneOf::Left(false)) {
|
} else if matches!(range_formatting_provider, Some(p) if *p != OneOf::Left(false)) {
|
||||||
let _timer = zlog::time!(logger => "format-range");
|
let _timer = zlog::time!(logger => "format-range");
|
||||||
let buffer_start = lsp::Position::new(0, 0);
|
let buffer_start = lsp::Position::new(0, 0);
|
||||||
let buffer_end = buffer.update(cx, |b, _| point_to_lsp(b.max_point_utf16()))?;
|
let buffer_end = buffer.read_with(cx, |b, _| point_to_lsp(b.max_point_utf16()))?;
|
||||||
language_server
|
language_server
|
||||||
.request::<lsp::request::RangeFormatting>(lsp::DocumentRangeFormattingParams {
|
.request::<lsp::request::RangeFormatting>(lsp::DocumentRangeFormattingParams {
|
||||||
text_document: text_document.clone(),
|
text_document: text_document.clone(),
|
||||||
|
@ -2029,7 +2029,7 @@ impl LocalLspStore {
|
||||||
let stdin = child.stdin.as_mut().context("failed to acquire stdin")?;
|
let stdin = child.stdin.as_mut().context("failed to acquire stdin")?;
|
||||||
let text = buffer
|
let text = buffer
|
||||||
.handle
|
.handle
|
||||||
.update(cx, |buffer, _| buffer.as_rope().clone())?;
|
.read_with(cx, |buffer, _| buffer.as_rope().clone())?;
|
||||||
for chunk in text.chunks() {
|
for chunk in text.chunks() {
|
||||||
stdin.write_all(chunk.as_bytes()).await?;
|
stdin.write_all(chunk.as_bytes()).await?;
|
||||||
}
|
}
|
||||||
|
@ -3038,7 +3038,7 @@ impl LocalLspStore {
|
||||||
) -> Result<lsp::ApplyWorkspaceEditResponse> {
|
) -> Result<lsp::ApplyWorkspaceEditResponse> {
|
||||||
let this = this.upgrade().context("project project closed")?;
|
let this = this.upgrade().context("project project closed")?;
|
||||||
let language_server = this
|
let language_server = this
|
||||||
.update(cx, |this, _| this.language_server_for_id(server_id))?
|
.read_with(cx, |this, _| this.language_server_for_id(server_id))?
|
||||||
.context("language server not found")?;
|
.context("language server not found")?;
|
||||||
let transaction = Self::deserialize_workspace_edit(
|
let transaction = Self::deserialize_workspace_edit(
|
||||||
this.clone(),
|
this.clone(),
|
||||||
|
@ -3851,9 +3851,9 @@ impl LspStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_buffer_added(&mut self, buffer: &Entity<Buffer>, cx: &mut Context<Self>) -> Result<()> {
|
fn on_buffer_added(&mut self, buffer: &Entity<Buffer>, cx: &mut Context<Self>) -> Result<()> {
|
||||||
buffer.update(cx, |buffer, _| {
|
buffer
|
||||||
buffer.set_language_registry(self.languages.clone())
|
.read(cx)
|
||||||
});
|
.set_language_registry(self.languages.clone());
|
||||||
|
|
||||||
cx.subscribe(buffer, |this, buffer, event, cx| {
|
cx.subscribe(buffer, |this, buffer, event, cx| {
|
||||||
this.on_buffer_event(buffer, event, cx);
|
this.on_buffer_event(buffer, event, cx);
|
||||||
|
@ -4691,7 +4691,9 @@ impl LspStore {
|
||||||
kind: kind.as_str().to_owned(),
|
kind: kind.as_str().to_owned(),
|
||||||
buffer_ids: buffers
|
buffer_ids: buffers
|
||||||
.iter()
|
.iter()
|
||||||
.map(|buffer| buffer.update(cx, |buffer, _| buffer.remote_id().into()))
|
.map(|buffer| {
|
||||||
|
buffer.read_with(cx, |buffer, _| buffer.remote_id().into())
|
||||||
|
})
|
||||||
.collect::<Result<_>>()?,
|
.collect::<Result<_>>()?,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
|
@ -6760,7 +6762,7 @@ impl LspStore {
|
||||||
})
|
})
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
if worktree.update(cx, |worktree, _| worktree.is_local())? {
|
if worktree.read_with(cx, |worktree, _| worktree.is_local())? {
|
||||||
lsp_store
|
lsp_store
|
||||||
.update(cx, |lsp_store, cx| {
|
.update(cx, |lsp_store, cx| {
|
||||||
lsp_store.register_local_language_server(
|
lsp_store.register_local_language_server(
|
||||||
|
@ -6772,7 +6774,7 @@ impl LspStore {
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
let worktree_root = worktree.update(cx, |worktree, _| worktree.abs_path())?;
|
let worktree_root = worktree.read_with(cx, |worktree, _| worktree.abs_path())?;
|
||||||
let relative_path = if let Some(known_path) = known_relative_path {
|
let relative_path = if let Some(known_path) = known_relative_path {
|
||||||
known_path
|
known_path
|
||||||
} else {
|
} else {
|
||||||
|
@ -6781,7 +6783,7 @@ impl LspStore {
|
||||||
(worktree, relative_path)
|
(worktree, relative_path)
|
||||||
};
|
};
|
||||||
let project_path = ProjectPath {
|
let project_path = ProjectPath {
|
||||||
worktree_id: worktree.update(cx, |worktree, _| worktree.id())?,
|
worktree_id: worktree.read_with(cx, |worktree, _| worktree.id())?,
|
||||||
path: relative_path,
|
path: relative_path,
|
||||||
};
|
};
|
||||||
lsp_store
|
lsp_store
|
||||||
|
@ -6897,7 +6899,7 @@ impl LspStore {
|
||||||
envelope: TypedEnvelope<proto::MultiLspQuery>,
|
envelope: TypedEnvelope<proto::MultiLspQuery>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::MultiLspQueryResponse> {
|
) -> Result<proto::MultiLspQueryResponse> {
|
||||||
let response_from_ssh = this.update(&mut cx, |this, _| {
|
let response_from_ssh = this.read_with(&mut cx, |this, _| {
|
||||||
let (upstream_client, project_id) = this.upstream_client()?;
|
let (upstream_client, project_id) = this.upstream_client()?;
|
||||||
let mut payload = envelope.payload.clone();
|
let mut payload = envelope.payload.clone();
|
||||||
payload.project_id = project_id;
|
payload.project_id = project_id;
|
||||||
|
@ -6919,7 +6921,7 @@ impl LspStore {
|
||||||
buffer.wait_for_version(version.clone())
|
buffer.wait_for_version(version.clone())
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
let buffer_version = buffer.update(&mut cx, |buffer, _| buffer.version())?;
|
let buffer_version = buffer.read_with(&mut cx, |buffer, _| buffer.version())?;
|
||||||
match envelope
|
match envelope
|
||||||
.payload
|
.payload
|
||||||
.strategy
|
.strategy
|
||||||
|
@ -7188,7 +7190,7 @@ impl LspStore {
|
||||||
})?
|
})?
|
||||||
.context("worktree not found")?;
|
.context("worktree not found")?;
|
||||||
let (old_abs_path, new_abs_path) = {
|
let (old_abs_path, new_abs_path) = {
|
||||||
let root_path = worktree.update(&mut cx, |this, _| this.abs_path())?;
|
let root_path = worktree.read_with(&mut cx, |this, _| this.abs_path())?;
|
||||||
let new_path = PathBuf::from_proto(envelope.payload.new_path.clone());
|
let new_path = PathBuf::from_proto(envelope.payload.new_path.clone());
|
||||||
(root_path.join(&old_path), root_path.join(&new_path))
|
(root_path.join(&old_path), root_path.join(&new_path))
|
||||||
};
|
};
|
||||||
|
@ -7203,7 +7205,7 @@ impl LspStore {
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
let response = Worktree::handle_rename_entry(worktree, envelope.payload, cx.clone()).await;
|
let response = Worktree::handle_rename_entry(worktree, envelope.payload, cx.clone()).await;
|
||||||
this.update(&mut cx, |this, _| {
|
this.read_with(&mut cx, |this, _| {
|
||||||
this.did_rename_entry(worktree_id, &old_abs_path, &new_abs_path, is_dir);
|
this.did_rename_entry(worktree_id, &old_abs_path, &new_abs_path, is_dir);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
|
@ -7386,7 +7388,7 @@ impl LspStore {
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::Ack> {
|
) -> Result<proto::Ack> {
|
||||||
let server_id = LanguageServerId(envelope.payload.language_server_id as usize);
|
let server_id = LanguageServerId(envelope.payload.language_server_id as usize);
|
||||||
lsp_store.update(&mut cx, |lsp_store, _| {
|
lsp_store.read_with(&mut cx, |lsp_store, _| {
|
||||||
if let Some(server) = lsp_store.language_server_for_id(server_id) {
|
if let Some(server) = lsp_store.language_server_for_id(server_id) {
|
||||||
server
|
server
|
||||||
.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(&())
|
.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(&())
|
||||||
|
@ -7438,7 +7440,7 @@ impl LspStore {
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<proto::Ack> {
|
) -> Result<proto::Ack> {
|
||||||
let server_id = LanguageServerId(envelope.payload.language_server_id as usize);
|
let server_id = LanguageServerId(envelope.payload.language_server_id as usize);
|
||||||
lsp_store.update(&mut cx, |lsp_store, _| {
|
lsp_store.read_with(&mut cx, |lsp_store, _| {
|
||||||
if let Some(server) = lsp_store.language_server_for_id(server_id) {
|
if let Some(server) = lsp_store.language_server_for_id(server_id) {
|
||||||
server
|
server
|
||||||
.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(&())
|
.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(&())
|
||||||
|
@ -8097,7 +8099,7 @@ impl LspStore {
|
||||||
let peer_id = envelope.original_sender_id().unwrap_or_default();
|
let peer_id = envelope.original_sender_id().unwrap_or_default();
|
||||||
let symbol = envelope.payload.symbol.context("invalid symbol")?;
|
let symbol = envelope.payload.symbol.context("invalid symbol")?;
|
||||||
let symbol = Self::deserialize_symbol(symbol)?;
|
let symbol = Self::deserialize_symbol(symbol)?;
|
||||||
let symbol = this.update(&mut cx, |this, _| {
|
let symbol = this.read_with(&mut cx, |this, _| {
|
||||||
let signature = this.symbol_signature(&symbol.path);
|
let signature = this.symbol_signature(&symbol.path);
|
||||||
anyhow::ensure!(signature == symbol.signature, "invalid symbol signature");
|
anyhow::ensure!(signature == symbol.signature, "invalid symbol signature");
|
||||||
Ok(symbol)
|
Ok(symbol)
|
||||||
|
@ -8392,7 +8394,7 @@ impl LspStore {
|
||||||
trigger: trigger as i32,
|
trigger: trigger as i32,
|
||||||
buffer_ids: buffers
|
buffer_ids: buffers
|
||||||
.iter()
|
.iter()
|
||||||
.map(|buffer| buffer.update(cx, |buffer, _| buffer.remote_id().into()))
|
.map(|buffer| buffer.read_with(cx, |buffer, _| buffer.remote_id().into()))
|
||||||
.collect::<Result<_>>()?,
|
.collect::<Result<_>>()?,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -117,7 +117,7 @@ impl LspCommand for ExpandMacro {
|
||||||
.and_then(deserialize_anchor)
|
.and_then(deserialize_anchor)
|
||||||
.context("invalid position")?;
|
.context("invalid position")?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ impl LspCommand for OpenDocs {
|
||||||
.and_then(deserialize_anchor)
|
.and_then(deserialize_anchor)
|
||||||
.context("invalid position")?;
|
.context("invalid position")?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ impl LspCommand for GoToParentModule {
|
||||||
.and_then(deserialize_anchor)
|
.and_then(deserialize_anchor)
|
||||||
.context("bad request with bad position")?;
|
.context("bad request with bad position")?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ pub fn cancel_flycheck(
|
||||||
else {
|
else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id().to_proto())?;
|
let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id().to_proto())?;
|
||||||
|
|
||||||
if let Some((client, project_id)) = upstream_client {
|
if let Some((client, project_id)) = upstream_client {
|
||||||
let request = proto::LspExtCancelFlycheck {
|
let request = proto::LspExtCancelFlycheck {
|
||||||
|
@ -123,7 +123,7 @@ pub fn cancel_flycheck(
|
||||||
.context("lsp ext cancel flycheck proto request")?;
|
.context("lsp ext cancel flycheck proto request")?;
|
||||||
} else {
|
} else {
|
||||||
lsp_store
|
lsp_store
|
||||||
.update(cx, |lsp_store, _| {
|
.read_with(cx, |lsp_store, _| {
|
||||||
if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {
|
if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {
|
||||||
server.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(&())?;
|
server.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(&())?;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ pub fn run_flycheck(
|
||||||
else {
|
else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id().to_proto())?;
|
let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id().to_proto())?;
|
||||||
|
|
||||||
if let Some((client, project_id)) = upstream_client {
|
if let Some((client, project_id)) = upstream_client {
|
||||||
let request = proto::LspExtRunFlycheck {
|
let request = proto::LspExtRunFlycheck {
|
||||||
|
@ -175,7 +175,7 @@ pub fn run_flycheck(
|
||||||
.context("lsp ext run flycheck proto request")?;
|
.context("lsp ext run flycheck proto request")?;
|
||||||
} else {
|
} else {
|
||||||
lsp_store
|
lsp_store
|
||||||
.update(cx, |lsp_store, _| {
|
.read_with(cx, |lsp_store, _| {
|
||||||
if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {
|
if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {
|
||||||
server.notify::<lsp_store::lsp_ext_command::LspExtRunFlycheck>(
|
server.notify::<lsp_store::lsp_ext_command::LspExtRunFlycheck>(
|
||||||
&lsp_store::lsp_ext_command::RunFlycheckParams {
|
&lsp_store::lsp_ext_command::RunFlycheckParams {
|
||||||
|
@ -216,7 +216,7 @@ pub fn clear_flycheck(
|
||||||
else {
|
else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id().to_proto())?;
|
let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id().to_proto())?;
|
||||||
|
|
||||||
if let Some((client, project_id)) = upstream_client {
|
if let Some((client, project_id)) = upstream_client {
|
||||||
let request = proto::LspExtClearFlycheck {
|
let request = proto::LspExtClearFlycheck {
|
||||||
|
@ -230,7 +230,7 @@ pub fn clear_flycheck(
|
||||||
.context("lsp ext clear flycheck proto request")?;
|
.context("lsp ext clear flycheck proto request")?;
|
||||||
} else {
|
} else {
|
||||||
lsp_store
|
lsp_store
|
||||||
.update(cx, |lsp_store, _| {
|
.read_with(cx, |lsp_store, _| {
|
||||||
if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {
|
if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {
|
||||||
server.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(&())?;
|
server.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(&())?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ impl ManifestTree {
|
||||||
};
|
};
|
||||||
|
|
||||||
let key = TriePath::from(&*path);
|
let key = TriePath::from(&*path);
|
||||||
worktree_roots.update(cx, |this, _| {
|
worktree_roots.read_with(cx, |this, _| {
|
||||||
this.roots.walk(&key, &mut |path, labels| {
|
this.roots.walk(&key, &mut |path, labels| {
|
||||||
for (label, presence) in labels {
|
for (label, presence) in labels {
|
||||||
if let Some((marked_path, current_presence)) = roots.get_mut(label) {
|
if let Some((marked_path, current_presence)) = roots.get_mut(label) {
|
||||||
|
|
|
@ -279,7 +279,7 @@ impl PrettierStore {
|
||||||
) -> PrettierTask {
|
) -> PrettierTask {
|
||||||
cx.spawn(async move |prettier_store, cx| {
|
cx.spawn(async move |prettier_store, cx| {
|
||||||
log::info!("Starting prettier at path {prettier_dir:?}");
|
log::info!("Starting prettier at path {prettier_dir:?}");
|
||||||
let new_server_id = prettier_store.update(cx, |prettier_store, _| {
|
let new_server_id = prettier_store.read_with(cx, |prettier_store, _| {
|
||||||
prettier_store.languages.next_language_server_id()
|
prettier_store.languages.next_language_server_id()
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ impl PrettierStore {
|
||||||
cx: &mut Context<PrettierStore>,
|
cx: &mut Context<PrettierStore>,
|
||||||
) -> Task<anyhow::Result<PrettierTask>> {
|
) -> Task<anyhow::Result<PrettierTask>> {
|
||||||
cx.spawn(async move |prettier_store, cx| {
|
cx.spawn(async move |prettier_store, cx| {
|
||||||
let installation_task = prettier_store.update(cx, |prettier_store, _| {
|
let installation_task = prettier_store.read_with(cx, |prettier_store, _| {
|
||||||
match &prettier_store.default_prettier.prettier {
|
match &prettier_store.default_prettier.prettier {
|
||||||
PrettierInstallation::NotInstalled {
|
PrettierInstallation::NotInstalled {
|
||||||
installation_task, ..
|
installation_task, ..
|
||||||
|
@ -407,7 +407,7 @@ impl PrettierStore {
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.worktree_for_id(id, cx)
|
.worktree_for_id(id, cx)
|
||||||
})
|
})
|
||||||
.map(|worktree| worktree.update(cx, |worktree, _| worktree.abs_path()));
|
.map(|worktree| worktree.read(cx).abs_path());
|
||||||
let name = match worktree_path {
|
let name = match worktree_path {
|
||||||
Some(worktree_path) => {
|
Some(worktree_path) => {
|
||||||
if prettier_dir == worktree_path.as_ref() {
|
if prettier_dir == worktree_path.as_ref() {
|
||||||
|
|
|
@ -1540,7 +1540,7 @@ impl Project {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tree.update(cx, |tree, _| tree.as_local().unwrap().scan_complete())
|
tree.read_with(cx, |tree, _| tree.as_local().unwrap().scan_complete())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -1579,7 +1579,7 @@ impl Project {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
tree.update(cx, |tree, _| tree.as_local().unwrap().scan_complete())
|
tree.read_with(cx, |tree, _| tree.as_local().unwrap().scan_complete())
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
project
|
project
|
||||||
|
@ -1945,7 +1945,7 @@ impl Project {
|
||||||
let lsp_store = self.lsp_store().downgrade();
|
let lsp_store = self.lsp_store().downgrade();
|
||||||
cx.spawn(async move |_, cx| {
|
cx.spawn(async move |_, cx| {
|
||||||
let (old_abs_path, new_abs_path) = {
|
let (old_abs_path, new_abs_path) = {
|
||||||
let root_path = worktree.update(cx, |this, _| this.abs_path())?;
|
let root_path = worktree.read_with(cx, |this, _| this.abs_path())?;
|
||||||
let new_abs_path = if is_root_entry {
|
let new_abs_path = if is_root_entry {
|
||||||
root_path.parent().unwrap().join(&new_path)
|
root_path.parent().unwrap().join(&new_path)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1970,7 +1970,7 @@ impl Project {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
lsp_store
|
lsp_store
|
||||||
.update(cx, |this, _| {
|
.read_with(cx, |this, _| {
|
||||||
this.did_rename_entry(worktree_id, &old_abs_path, &new_abs_path, is_dir);
|
this.did_rename_entry(worktree_id, &old_abs_path, &new_abs_path, is_dir);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
|
@ -2550,7 +2550,7 @@ impl Project {
|
||||||
cx: &mut AsyncApp,
|
cx: &mut AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
for (buffer_id, operations) in operations_by_buffer_id.drain() {
|
for (buffer_id, operations) in operations_by_buffer_id.drain() {
|
||||||
let request = this.update(cx, |this, _| {
|
let request = this.read_with(cx, |this, _| {
|
||||||
let project_id = this.remote_id()?;
|
let project_id = this.remote_id()?;
|
||||||
Some(this.client.request(proto::UpdateBuffer {
|
Some(this.client.request(proto::UpdateBuffer {
|
||||||
buffer_id: buffer_id.into(),
|
buffer_id: buffer_id.into(),
|
||||||
|
@ -2572,7 +2572,7 @@ impl Project {
|
||||||
let mut changes = rx.ready_chunks(MAX_BATCH_SIZE);
|
let mut changes = rx.ready_chunks(MAX_BATCH_SIZE);
|
||||||
|
|
||||||
while let Some(changes) = changes.next().await {
|
while let Some(changes) = changes.next().await {
|
||||||
let is_local = this.update(cx, |this, _| this.is_local())?;
|
let is_local = this.read_with(cx, |this, _| this.is_local())?;
|
||||||
|
|
||||||
for change in changes {
|
for change in changes {
|
||||||
match change {
|
match change {
|
||||||
|
@ -2614,7 +2614,7 @@ impl Project {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
this.update(cx, |this, _| {
|
this.read_with(cx, |this, _| {
|
||||||
if let Some(project_id) = this.remote_id() {
|
if let Some(project_id) = this.remote_id() {
|
||||||
this.client
|
this.client
|
||||||
.send(proto::UpdateLanguageServer {
|
.send(proto::UpdateLanguageServer {
|
||||||
|
@ -4007,7 +4007,7 @@ impl Project {
|
||||||
cx: &mut AsyncApp,
|
cx: &mut AsyncApp,
|
||||||
) -> Option<ResolvedPath> {
|
) -> Option<ResolvedPath> {
|
||||||
worktree
|
worktree
|
||||||
.update(cx, |worktree, _| {
|
.read_with(cx, |worktree, _| {
|
||||||
let root_entry_path = &worktree.root_entry()?.path;
|
let root_entry_path = &worktree.root_entry()?.path;
|
||||||
let resolved = resolve_path(root_entry_path, path);
|
let resolved = resolve_path(root_entry_path, path);
|
||||||
let stripped = resolved.strip_prefix(root_entry_path).unwrap_or(&resolved);
|
let stripped = resolved.strip_prefix(root_entry_path).unwrap_or(&resolved);
|
||||||
|
|
|
@ -902,7 +902,7 @@ impl SettingsObserver {
|
||||||
let user_tasks_content = cx.background_executor().block(user_tasks_file_rx.next());
|
let user_tasks_content = cx.background_executor().block(user_tasks_file_rx.next());
|
||||||
let weak_entry = cx.weak_entity();
|
let weak_entry = cx.weak_entity();
|
||||||
cx.spawn(async move |settings_observer, cx| {
|
cx.spawn(async move |settings_observer, cx| {
|
||||||
let Ok(task_store) = settings_observer.update(cx, |settings_observer, _| {
|
let Ok(task_store) = settings_observer.read_with(cx, |settings_observer, _| {
|
||||||
settings_observer.task_store.clone()
|
settings_observer.task_store.clone()
|
||||||
}) else {
|
}) else {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl TaskStore {
|
||||||
.payload
|
.payload
|
||||||
.location
|
.location
|
||||||
.context("no location given for task context handling")?;
|
.context("no location given for task context handling")?;
|
||||||
let (buffer_store, is_remote) = store.update(&mut cx, |store, _| {
|
let (buffer_store, is_remote) = store.read_with(&mut cx, |store, _| {
|
||||||
Ok(match store {
|
Ok(match store {
|
||||||
TaskStore::Functional(state) => (
|
TaskStore::Functional(state) => (
|
||||||
state.buffer_store.clone(),
|
state.buffer_store.clone(),
|
||||||
|
|
|
@ -367,7 +367,7 @@ impl WorktreeStore {
|
||||||
|
|
||||||
let handle_id = worktree.entity_id();
|
let handle_id = worktree.entity_id();
|
||||||
cx.subscribe(worktree, |_, worktree, event, cx| {
|
cx.subscribe(worktree, |_, worktree, event, cx| {
|
||||||
let worktree_id = worktree.update(cx, |worktree, _| worktree.id());
|
let worktree_id = worktree.read(cx).id();
|
||||||
match event {
|
match event {
|
||||||
worktree::Event::UpdatedEntries(changes) => {
|
worktree::Event::UpdatedEntries(changes) => {
|
||||||
cx.emit(WorktreeStoreEvent::WorktreeUpdatedEntries(
|
cx.emit(WorktreeStoreEvent::WorktreeUpdatedEntries(
|
||||||
|
|
|
@ -93,7 +93,7 @@ impl YarnPathStore {
|
||||||
let zip_file: Arc<Path> = Arc::from(zip_file);
|
let zip_file: Arc<Path> = Arc::from(zip_file);
|
||||||
cx.spawn(async move |this, cx| {
|
cx.spawn(async move |this, cx| {
|
||||||
let dir = this
|
let dir = this
|
||||||
.update(cx, |this, _| {
|
.read_with(cx, |this, _| {
|
||||||
this.temp_dirs
|
this.temp_dirs
|
||||||
.get(&zip_file)
|
.get(&zip_file)
|
||||||
.map(|temp| temp.path().to_owned())
|
.map(|temp| temp.path().to_owned())
|
||||||
|
|
|
@ -694,7 +694,7 @@ impl ProjectPanel {
|
||||||
fn serialize(&mut self, cx: &mut Context<Self>) {
|
fn serialize(&mut self, cx: &mut Context<Self>) {
|
||||||
let Some(serialization_key) = self
|
let Some(serialization_key) = self
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |workspace, _| {
|
.read_with(cx, |workspace, _| {
|
||||||
ProjectPanel::serialization_key(workspace)
|
ProjectPanel::serialization_key(workspace)
|
||||||
})
|
})
|
||||||
.ok()
|
.ok()
|
||||||
|
@ -3457,7 +3457,7 @@ impl ProjectPanel {
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.repo_snapshots(cx);
|
.repo_snapshots(cx);
|
||||||
let worktree = self.project.read(cx).worktree_for_id(worktree_id, cx)?;
|
let worktree = self.project.read(cx).worktree_for_id(worktree_id, cx)?;
|
||||||
worktree.update(cx, |tree, _| {
|
worktree.read_with(cx, |tree, _| {
|
||||||
utils::ReversibleIterable::new(
|
utils::ReversibleIterable::new(
|
||||||
GitTraversal::new(&repo_snapshots, tree.entries(true, 0usize)),
|
GitTraversal::new(&repo_snapshots, tree.entries(true, 0usize)),
|
||||||
reverse_search,
|
reverse_search,
|
||||||
|
@ -3492,16 +3492,17 @@ impl ProjectPanel {
|
||||||
let worktree = self
|
let worktree = self
|
||||||
.project
|
.project
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.worktree_for_id(start.worktree_id, cx)?;
|
.worktree_for_id(start.worktree_id, cx)?
|
||||||
|
.read(cx);
|
||||||
|
|
||||||
let search = worktree.update(cx, |tree, _| {
|
let search = {
|
||||||
let entry = tree.entry_for_id(start.entry_id)?;
|
let entry = worktree.entry_for_id(start.entry_id)?;
|
||||||
let root_entry = tree.root_entry()?;
|
let root_entry = worktree.root_entry()?;
|
||||||
let tree_id = tree.id();
|
let tree_id = worktree.id();
|
||||||
|
|
||||||
let mut first_iter = GitTraversal::new(
|
let mut first_iter = GitTraversal::new(
|
||||||
&repo_snapshots,
|
&repo_snapshots,
|
||||||
tree.traverse_from_path(true, true, true, entry.path.as_ref()),
|
worktree.traverse_from_path(true, true, true, entry.path.as_ref()),
|
||||||
);
|
);
|
||||||
|
|
||||||
if reverse_search {
|
if reverse_search {
|
||||||
|
@ -3515,7 +3516,8 @@ impl ProjectPanel {
|
||||||
.find(|ele| predicate(*ele, tree_id))
|
.find(|ele| predicate(*ele, tree_id))
|
||||||
.map(|ele| ele.to_owned());
|
.map(|ele| ele.to_owned());
|
||||||
|
|
||||||
let second_iter = GitTraversal::new(&repo_snapshots, tree.entries(true, 0usize));
|
let second_iter =
|
||||||
|
GitTraversal::new(&repo_snapshots, worktree.entries(true, 0usize));
|
||||||
|
|
||||||
let second = if reverse_search {
|
let second = if reverse_search {
|
||||||
second_iter
|
second_iter
|
||||||
|
@ -3536,7 +3538,7 @@ impl ProjectPanel {
|
||||||
} else {
|
} else {
|
||||||
Some((first, second))
|
Some((first, second))
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
if let Some((first, second)) = search {
|
if let Some((first, second)) = search {
|
||||||
let first = first.map(|entry| SelectedEntry {
|
let first = first.map(|entry| SelectedEntry {
|
||||||
|
|
|
@ -381,7 +381,7 @@ mod tests {
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
symbols.update(cx, |symbols, _| {
|
symbols.read_with(cx, |symbols, _| {
|
||||||
assert_eq!(symbols.delegate.matches.len(), 0);
|
assert_eq!(symbols.delegate.matches.len(), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ mod tests {
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
symbols.update(cx, |symbols, _| {
|
symbols.read_with(cx, |symbols, _| {
|
||||||
let delegate = &symbols.delegate;
|
let delegate = &symbols.delegate;
|
||||||
assert_eq!(delegate.matches.len(), 2);
|
assert_eq!(delegate.matches.len(), 2);
|
||||||
assert_eq!(delegate.matches[0].string, "ton");
|
assert_eq!(delegate.matches[0].string, "ton");
|
||||||
|
@ -406,7 +406,7 @@ mod tests {
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
symbols.update(cx, |symbols, _| {
|
symbols.read_with(cx, |symbols, _| {
|
||||||
assert_eq!(symbols.delegate.matches.len(), 0);
|
assert_eq!(symbols.delegate.matches.len(), 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ impl ProjectPicker {
|
||||||
};
|
};
|
||||||
|
|
||||||
let app_state = workspace
|
let app_state = workspace
|
||||||
.update(cx, |workspace, _| workspace.app_state().clone())
|
.read_with(cx, |workspace, _| workspace.app_state().clone())
|
||||||
.ok()?;
|
.ok()?;
|
||||||
|
|
||||||
cx.update(|_, cx| {
|
cx.update(|_, cx| {
|
||||||
|
@ -856,7 +856,7 @@ impl RemoteServerProjects {
|
||||||
move |this: &mut Self, window: &mut Window, cx: &mut Context<Self>| {
|
move |this: &mut Self, window: &mut Window, cx: &mut Context<Self>| {
|
||||||
let Some(app_state) = this
|
let Some(app_state) = this
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |workspace, _| workspace.app_state().clone())
|
.read_with(cx, |workspace, _| workspace.app_state().clone())
|
||||||
.log_err()
|
.log_err()
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
|
@ -940,7 +940,7 @@ impl RemoteServerProjects {
|
||||||
) {
|
) {
|
||||||
let Some(fs) = self
|
let Some(fs) = self
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |workspace, _| workspace.app_state().fs.clone())
|
.read_with(cx, |workspace, _| workspace.app_state().fs.clone())
|
||||||
.log_err()
|
.log_err()
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -901,7 +901,7 @@ impl SshRemoteClient {
|
||||||
mut connection_activity_rx: mpsc::Receiver<()>,
|
mut connection_activity_rx: mpsc::Receiver<()>,
|
||||||
cx: &mut AsyncApp,
|
cx: &mut AsyncApp,
|
||||||
) -> Task<Result<()>> {
|
) -> Task<Result<()>> {
|
||||||
let Ok(client) = this.update(cx, |this, _| this.client.clone()) else {
|
let Ok(client) = this.read_with(cx, |this, _| this.client.clone()) else {
|
||||||
return Task::ready(Err(anyhow!("SshRemoteClient lost")));
|
return Task::ready(Err(anyhow!("SshRemoteClient lost")));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -383,7 +383,7 @@ impl HeadlessProject {
|
||||||
};
|
};
|
||||||
|
|
||||||
let worktree = this
|
let worktree = this
|
||||||
.update(&mut cx.clone(), |this, _| {
|
.read_with(&mut cx.clone(), |this, _| {
|
||||||
Worktree::local(
|
Worktree::local(
|
||||||
Arc::from(canonicalized.as_path()),
|
Arc::from(canonicalized.as_path()),
|
||||||
message.payload.visible,
|
message.payload.visible,
|
||||||
|
@ -394,11 +394,12 @@ impl HeadlessProject {
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let response = this.update(&mut cx, |_, cx| {
|
let response = this.read_with(&mut cx, |_, cx| {
|
||||||
worktree.update(cx, |worktree, _| proto::AddWorktreeResponse {
|
let worktree = worktree.read(cx);
|
||||||
|
proto::AddWorktreeResponse {
|
||||||
worktree_id: worktree.id().to_proto(),
|
worktree_id: worktree.id().to_proto(),
|
||||||
canonicalized_path: canonicalized.to_proto(),
|
canonicalized_path: canonicalized.to_proto(),
|
||||||
})
|
}
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// We spawn this asynchronously, so that we can send the response back
|
// We spawn this asynchronously, so that we can send the response back
|
||||||
|
@ -572,7 +573,7 @@ impl HeadlessProject {
|
||||||
let buffer_store = this.read_with(&cx, |this, _| this.buffer_store.clone())?;
|
let buffer_store = this.read_with(&cx, |this, _| this.buffer_store.clone())?;
|
||||||
|
|
||||||
while let Ok(buffer) = results.recv().await {
|
while let Ok(buffer) = results.recv().await {
|
||||||
let buffer_id = buffer.update(&mut cx, |this, _| this.remote_id())?;
|
let buffer_id = buffer.read_with(&mut cx, |this, _| this.remote_id())?;
|
||||||
response.buffer_ids.push(buffer_id.to_proto());
|
response.buffer_ids.push(buffer_id.to_proto());
|
||||||
buffer_store
|
buffer_store
|
||||||
.update(&mut cx, |buffer_store, cx| {
|
.update(&mut cx, |buffer_store, cx| {
|
||||||
|
|
|
@ -696,9 +696,9 @@ impl BufferSearchBar {
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.as_singleton()
|
.as_singleton()
|
||||||
.expect("query editor should be backed by a singleton buffer");
|
.expect("query editor should be backed by a singleton buffer");
|
||||||
query_buffer.update(cx, |query_buffer, _| {
|
query_buffer
|
||||||
query_buffer.set_language_registry(languages.clone());
|
.read(cx)
|
||||||
});
|
.set_language_registry(languages.clone());
|
||||||
|
|
||||||
cx.spawn(async move |buffer_search_bar, cx| {
|
cx.spawn(async move |buffer_search_bar, cx| {
|
||||||
let regex_language = languages
|
let regex_language = languages
|
||||||
|
@ -1692,7 +1692,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(0));
|
assert_eq!(search_bar.active_match_index, Some(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1703,7 +1703,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]
|
[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(1));
|
assert_eq!(search_bar.active_match_index, Some(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1714,7 +1714,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(2));
|
assert_eq!(search_bar.active_match_index, Some(2));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1725,7 +1725,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(0));
|
assert_eq!(search_bar.active_match_index, Some(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1736,7 +1736,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(2));
|
assert_eq!(search_bar.active_match_index, Some(2));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1747,7 +1747,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]
|
[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(1));
|
assert_eq!(search_bar.active_match_index, Some(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1758,7 +1758,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(0));
|
assert_eq!(search_bar.active_match_index, Some(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1779,7 +1779,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(0));
|
assert_eq!(search_bar.active_match_index, Some(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1800,7 +1800,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]
|
[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(1));
|
assert_eq!(search_bar.active_match_index, Some(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1821,7 +1821,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(2));
|
assert_eq!(search_bar.active_match_index, Some(2));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1842,7 +1842,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(0));
|
assert_eq!(search_bar.active_match_index, Some(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1863,7 +1863,7 @@ mod tests {
|
||||||
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
search_bar.update(cx, |search_bar, _| {
|
search_bar.read_with(cx, |search_bar, _| {
|
||||||
assert_eq!(search_bar.active_match_index, Some(2));
|
assert_eq!(search_bar.active_match_index, Some(2));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -4019,7 +4019,7 @@ pub mod tests {
|
||||||
window
|
window
|
||||||
.update(cx, |workspace, window, cx| {
|
.update(cx, |workspace, window, cx| {
|
||||||
assert_eq!(workspace.active_pane(), &first_pane);
|
assert_eq!(workspace.active_pane(), &first_pane);
|
||||||
first_pane.update(cx, |this, _| {
|
first_pane.read_with(cx, |this, _| {
|
||||||
assert_eq!(this.active_item_index(), 1);
|
assert_eq!(this.active_item_index(), 1);
|
||||||
assert_eq!(this.items_len(), 2);
|
assert_eq!(this.items_len(), 2);
|
||||||
});
|
});
|
||||||
|
@ -4203,7 +4203,7 @@ pub mod tests {
|
||||||
});
|
});
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
let project_search_view = pane
|
let project_search_view = pane
|
||||||
.update(&mut cx, |pane, _| {
|
.read_with(&mut cx, |pane, _| {
|
||||||
pane.active_item()
|
pane.active_item()
|
||||||
.and_then(|item| item.downcast::<ProjectSearchView>())
|
.and_then(|item| item.downcast::<ProjectSearchView>())
|
||||||
})
|
})
|
||||||
|
|
|
@ -69,7 +69,7 @@ async fn process_updates(
|
||||||
entries: Vec<PathBuf>,
|
entries: Vec<PathBuf>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let fs = this.update(&mut cx, |this, _| this.fs.clone())?;
|
let fs = this.read_with(&mut cx, |this, _| this.fs.clone())?;
|
||||||
for entry_path in entries {
|
for entry_path in entries {
|
||||||
if !entry_path
|
if !entry_path
|
||||||
.extension()
|
.extension()
|
||||||
|
@ -120,7 +120,7 @@ async fn initial_scan(
|
||||||
path: Arc<Path>,
|
path: Arc<Path>,
|
||||||
mut cx: AsyncApp,
|
mut cx: AsyncApp,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let fs = this.update(&mut cx, |this, _| this.fs.clone())?;
|
let fs = this.read_with(&mut cx, |this, _| this.fs.clone())?;
|
||||||
let entries = fs.read_dir(&path).await;
|
let entries = fs.read_dir(&path).await;
|
||||||
if let Ok(entries) = entries {
|
if let Ok(entries) = entries {
|
||||||
let entries = entries
|
let entries = entries
|
||||||
|
@ -183,7 +183,7 @@ impl SnippetProvider {
|
||||||
let path: Arc<Path> = Arc::from(path);
|
let path: Arc<Path> = Arc::from(path);
|
||||||
|
|
||||||
self.watch_tasks.push(cx.spawn(async move |this, cx| {
|
self.watch_tasks.push(cx.spawn(async move |this, cx| {
|
||||||
let fs = this.update(cx, |this, _| this.fs.clone())?;
|
let fs = this.read_with(cx, |this, _| this.fs.clone())?;
|
||||||
let watched_path = path.clone();
|
let watched_path = path.clone();
|
||||||
let watcher = fs.watch(&watched_path, Duration::from_secs(1));
|
let watcher = fs.watch(&watched_path, Duration::from_secs(1));
|
||||||
initial_scan(this.clone(), path, cx.clone()).await?;
|
initial_scan(this.clone(), path, cx.clone()).await?;
|
||||||
|
|
|
@ -1176,7 +1176,7 @@ mod tests {
|
||||||
scheduled_task_label: &str,
|
scheduled_task_label: &str,
|
||||||
cx: &mut VisualTestContext,
|
cx: &mut VisualTestContext,
|
||||||
) {
|
) {
|
||||||
let scheduled_task = tasks_picker.update(cx, |tasks_picker, _| {
|
let scheduled_task = tasks_picker.read_with(cx, |tasks_picker, _| {
|
||||||
tasks_picker
|
tasks_picker
|
||||||
.delegate
|
.delegate
|
||||||
.candidates
|
.candidates
|
||||||
|
@ -1220,14 +1220,14 @@ mod tests {
|
||||||
spawn_tasks: &Entity<Picker<TasksModalDelegate>>,
|
spawn_tasks: &Entity<Picker<TasksModalDelegate>>,
|
||||||
cx: &mut VisualTestContext,
|
cx: &mut VisualTestContext,
|
||||||
) -> String {
|
) -> String {
|
||||||
spawn_tasks.update(cx, |spawn_tasks, cx| spawn_tasks.query(cx))
|
spawn_tasks.read_with(cx, |spawn_tasks, cx| spawn_tasks.query(cx))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn task_names(
|
fn task_names(
|
||||||
spawn_tasks: &Entity<Picker<TasksModalDelegate>>,
|
spawn_tasks: &Entity<Picker<TasksModalDelegate>>,
|
||||||
cx: &mut VisualTestContext,
|
cx: &mut VisualTestContext,
|
||||||
) -> Vec<String> {
|
) -> Vec<String> {
|
||||||
spawn_tasks.update(cx, |spawn_tasks, _| {
|
spawn_tasks.read_with(cx, |spawn_tasks, _| {
|
||||||
spawn_tasks
|
spawn_tasks
|
||||||
.delegate
|
.delegate
|
||||||
.matches
|
.matches
|
||||||
|
|
|
@ -300,9 +300,12 @@ pub fn task_contexts(
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let latest_selection = active_editor.as_ref().map(|active_editor| {
|
let latest_selection = active_editor.as_ref().map(|active_editor| {
|
||||||
active_editor.update(cx, |editor, _| {
|
active_editor
|
||||||
editor.selections.newest_anchor().head().text_anchor
|
.read(cx)
|
||||||
})
|
.selections
|
||||||
|
.newest_anchor()
|
||||||
|
.head()
|
||||||
|
.text_anchor
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut worktree_abs_paths = workspace
|
let mut worktree_abs_paths = workspace
|
||||||
|
@ -412,7 +415,7 @@ mod tests {
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
let project = Project::test(fs, [path!("/dir").as_ref()], cx).await;
|
let project = Project::test(fs, [path!("/dir").as_ref()], cx).await;
|
||||||
let worktree_store = project.update(cx, |project, _| project.worktree_store().clone());
|
let worktree_store = project.read_with(cx, |project, _| project.worktree_store().clone());
|
||||||
let rust_language = Arc::new(
|
let rust_language = Arc::new(
|
||||||
Language::new(
|
Language::new(
|
||||||
LanguageConfig::default(),
|
LanguageConfig::default(),
|
||||||
|
|
|
@ -702,7 +702,7 @@ impl TerminalPanel {
|
||||||
terminal_panel.pending_terminals_to_add += 1;
|
terminal_panel.pending_terminals_to_add += 1;
|
||||||
terminal_panel.active_pane.clone()
|
terminal_panel.active_pane.clone()
|
||||||
})?;
|
})?;
|
||||||
let project = workspace.update(cx, |workspace, _| workspace.project().clone())?;
|
let project = workspace.read_with(cx, |workspace, _| workspace.project().clone())?;
|
||||||
let window_handle = cx.window_handle();
|
let window_handle = cx.window_handle();
|
||||||
let terminal = project
|
let terminal = project
|
||||||
.update(cx, |project, cx| {
|
.update(cx, |project, cx| {
|
||||||
|
@ -754,7 +754,7 @@ impl TerminalPanel {
|
||||||
let width = self.width;
|
let width = self.width;
|
||||||
let Some(serialization_key) = self
|
let Some(serialization_key) = self
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |workspace, _| {
|
.read_with(cx, |workspace, _| {
|
||||||
TerminalPanel::serialization_key(workspace)
|
TerminalPanel::serialization_key(workspace)
|
||||||
})
|
})
|
||||||
.ok()
|
.ok()
|
||||||
|
@ -972,7 +972,7 @@ pub fn new_terminal_pane(
|
||||||
if let Some(tab) = dragged_item.downcast_ref::<DraggedTab>() {
|
if let Some(tab) = dragged_item.downcast_ref::<DraggedTab>() {
|
||||||
let is_current_pane = tab.pane == cx.entity();
|
let is_current_pane = tab.pane == cx.entity();
|
||||||
let Some(can_drag_away) = split_closure_terminal_panel
|
let Some(can_drag_away) = split_closure_terminal_panel
|
||||||
.update(cx, |terminal_panel, _| {
|
.read_with(cx, |terminal_panel, _| {
|
||||||
let current_panes = terminal_panel.center.panes();
|
let current_panes = terminal_panel.center.panes();
|
||||||
!current_panes.contains(&&tab.pane)
|
!current_panes.contains(&&tab.pane)
|
||||||
|| current_panes.len() > 1
|
|| current_panes.len() > 1
|
||||||
|
|
|
@ -389,11 +389,9 @@ impl TerminalView {
|
||||||
fn rerun_task(&mut self, _: &RerunTask, window: &mut Window, cx: &mut Context<Self>) {
|
fn rerun_task(&mut self, _: &RerunTask, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
let task = self
|
let task = self
|
||||||
.terminal
|
.terminal
|
||||||
.update(cx, |terminal, _| {
|
.read(cx)
|
||||||
terminal
|
|
||||||
.task()
|
.task()
|
||||||
.map(|task| terminal_rerun_override(&task.id))
|
.map(|task| terminal_rerun_override(&task.id))
|
||||||
})
|
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
window.dispatch_action(Box::new(task), cx);
|
window.dispatch_action(Box::new(task), cx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,16 +56,16 @@ impl ActiveToolchain {
|
||||||
fn spawn_tracker_task(window: &mut Window, cx: &mut Context<Self>) -> Task<Option<()>> {
|
fn spawn_tracker_task(window: &mut Window, cx: &mut Context<Self>) -> Task<Option<()>> {
|
||||||
cx.spawn_in(window, async move |this, cx| {
|
cx.spawn_in(window, async move |this, cx| {
|
||||||
let active_file = this
|
let active_file = this
|
||||||
.update(cx, |this, _| {
|
.read_with(cx, |this, _| {
|
||||||
this.active_buffer
|
this.active_buffer
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|(_, buffer, _)| buffer.clone())
|
.map(|(_, buffer, _)| buffer.clone())
|
||||||
})
|
})
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()?;
|
.flatten()?;
|
||||||
let workspace = this.update(cx, |this, _| this.workspace.clone()).ok()?;
|
let workspace = this.read_with(cx, |this, _| this.workspace.clone()).ok()?;
|
||||||
let language_name = active_file
|
let language_name = active_file
|
||||||
.update(cx, |this, _| Some(this.language()?.name()))
|
.read_with(cx, |this, _| Some(this.language()?.name()))
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()?;
|
.flatten()?;
|
||||||
let term = workspace
|
let term = workspace
|
||||||
|
@ -136,7 +136,7 @@ impl ActiveToolchain {
|
||||||
) -> Task<Option<Toolchain>> {
|
) -> Task<Option<Toolchain>> {
|
||||||
cx.spawn(async move |cx| {
|
cx.spawn(async move |cx| {
|
||||||
let workspace_id = workspace
|
let workspace_id = workspace
|
||||||
.update(cx, |this, _| this.database_id())
|
.read_with(cx, |this, _| this.database_id())
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()?;
|
.flatten()?;
|
||||||
let selected_toolchain = workspace
|
let selected_toolchain = workspace
|
||||||
|
@ -156,7 +156,7 @@ impl ActiveToolchain {
|
||||||
Some(toolchain)
|
Some(toolchain)
|
||||||
} else {
|
} else {
|
||||||
let project = workspace
|
let project = workspace
|
||||||
.update(cx, |this, _| this.project().clone())
|
.read_with(cx, |this, _| this.project().clone())
|
||||||
.ok()?;
|
.ok()?;
|
||||||
let toolchains = cx
|
let toolchains = cx
|
||||||
.update(|_, cx| {
|
.update(|_, cx| {
|
||||||
|
|
|
@ -164,13 +164,13 @@ impl ToolchainSelectorDelegate {
|
||||||
let project = project.clone();
|
let project = project.clone();
|
||||||
async move |this, cx| {
|
async move |this, cx| {
|
||||||
let term = project
|
let term = project
|
||||||
.update(cx, |this, _| {
|
.read_with(cx, |this, _| {
|
||||||
Project::toolchain_term(this.languages().clone(), language_name.clone())
|
Project::toolchain_term(this.languages().clone(), language_name.clone())
|
||||||
})
|
})
|
||||||
.ok()?
|
.ok()?
|
||||||
.await?;
|
.await?;
|
||||||
let relative_path = this
|
let relative_path = this
|
||||||
.update(cx, |this, _| this.delegate.relative_path.clone())
|
.read_with(cx, |this, _| this.delegate.relative_path.clone())
|
||||||
.ok()?;
|
.ok()?;
|
||||||
let placeholder_text = format!(
|
let placeholder_text = format!(
|
||||||
"Select a {} for `{}`…",
|
"Select a {} for `{}`…",
|
||||||
|
@ -257,7 +257,7 @@ impl PickerDelegate for ToolchainSelectorDelegate {
|
||||||
let toolchain = self.candidates.toolchains[string_match.candidate_id].clone();
|
let toolchain = self.candidates.toolchains[string_match.candidate_id].clone();
|
||||||
if let Some(workspace_id) = self
|
if let Some(workspace_id) = self
|
||||||
.workspace
|
.workspace
|
||||||
.update(cx, |this, _| this.database_id())
|
.read_with(cx, |this, _| this.database_id())
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()
|
.flatten()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1762,7 +1762,7 @@ impl Pane {
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
let Some(item_ix) = pane
|
let Some(item_ix) = pane
|
||||||
.update(cx, |pane, _| pane.index_for_item(item))
|
.read_with(cx, |pane, _| pane.index_for_item(item))
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()
|
.flatten()
|
||||||
else {
|
else {
|
||||||
|
@ -2017,7 +2017,8 @@ impl Pane {
|
||||||
let pane = cx.entity().clone();
|
let pane = cx.entity().clone();
|
||||||
|
|
||||||
window.defer(cx, move |window, cx| {
|
window.defer(cx, move |window, cx| {
|
||||||
let Ok(status_bar) = workspace.update(cx, |workspace, _| workspace.status_bar.clone())
|
let Ok(status_bar) =
|
||||||
|
workspace.read_with(cx, |workspace, _| workspace.status_bar.clone())
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -3760,7 +3761,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
pane.update_in(cx, |pane, window, cx| {
|
pane.update_in(cx, |pane, window, cx| {
|
||||||
assert!(
|
assert!(
|
||||||
|
@ -3785,7 +3786,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
for i in 0..7 {
|
for i in 0..7 {
|
||||||
add_labeled_item(&pane, format!("{}", i).as_str(), false, cx);
|
add_labeled_item(&pane, format!("{}", i).as_str(), false, cx);
|
||||||
|
@ -3834,7 +3835,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
// 1. Add with a destination index
|
// 1. Add with a destination index
|
||||||
// a. Add before the active item
|
// a. Add before the active item
|
||||||
|
@ -3917,7 +3918,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
// 1. Add with a destination index
|
// 1. Add with a destination index
|
||||||
// 1a. Add before the active item
|
// 1a. Add before the active item
|
||||||
|
@ -3993,7 +3994,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
// singleton view
|
// singleton view
|
||||||
pane.update_in(cx, |pane, window, cx| {
|
pane.update_in(cx, |pane, window, cx| {
|
||||||
|
@ -4098,7 +4099,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
add_labeled_item(&pane, "A", false, cx);
|
add_labeled_item(&pane, "A", false, cx);
|
||||||
add_labeled_item(&pane, "B", false, cx);
|
add_labeled_item(&pane, "B", false, cx);
|
||||||
|
@ -4191,7 +4192,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
add_labeled_item(&pane, "A", false, cx);
|
add_labeled_item(&pane, "A", false, cx);
|
||||||
add_labeled_item(&pane, "B", false, cx);
|
add_labeled_item(&pane, "B", false, cx);
|
||||||
|
@ -4284,7 +4285,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
add_labeled_item(&pane, "A", false, cx);
|
add_labeled_item(&pane, "A", false, cx);
|
||||||
add_labeled_item(&pane, "B", false, cx);
|
add_labeled_item(&pane, "B", false, cx);
|
||||||
|
@ -4377,7 +4378,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
set_labeled_items(&pane, ["A", "B", "C*", "D", "E"], cx);
|
set_labeled_items(&pane, ["A", "B", "C*", "D", "E"], cx);
|
||||||
|
|
||||||
|
@ -4405,7 +4406,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
add_labeled_item(&pane, "A", true, cx);
|
add_labeled_item(&pane, "A", true, cx);
|
||||||
add_labeled_item(&pane, "B", false, cx);
|
add_labeled_item(&pane, "B", false, cx);
|
||||||
|
@ -4437,7 +4438,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
set_labeled_items(&pane, ["A", "B", "C*", "D", "E"], cx);
|
set_labeled_items(&pane, ["A", "B", "C*", "D", "E"], cx);
|
||||||
|
|
||||||
|
@ -4464,7 +4465,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
set_labeled_items(&pane, ["A", "B", "C*", "D", "E"], cx);
|
set_labeled_items(&pane, ["A", "B", "C*", "D", "E"], cx);
|
||||||
|
|
||||||
|
@ -4491,7 +4492,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
let item_a = add_labeled_item(&pane, "A", false, cx);
|
let item_a = add_labeled_item(&pane, "A", false, cx);
|
||||||
add_labeled_item(&pane, "B", false, cx);
|
add_labeled_item(&pane, "B", false, cx);
|
||||||
|
@ -4596,7 +4597,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
let a = cx.update(|_, cx| TestProjectItem::new_dirty(1, "A.txt", cx));
|
let a = cx.update(|_, cx| TestProjectItem::new_dirty(1, "A.txt", cx));
|
||||||
let b = cx.update(|_, cx| TestProjectItem::new_dirty(1, "B.txt", cx));
|
let b = cx.update(|_, cx| TestProjectItem::new_dirty(1, "B.txt", cx));
|
||||||
|
@ -4640,7 +4641,7 @@ mod tests {
|
||||||
let project = Project::test(fs, None, cx).await;
|
let project = Project::test(fs, None, cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
let item_a = add_labeled_item(&pane, "A", false, cx);
|
let item_a = add_labeled_item(&pane, "A", false, cx);
|
||||||
add_labeled_item(&pane, "B", false, cx);
|
add_labeled_item(&pane, "B", false, cx);
|
||||||
|
@ -4674,7 +4675,7 @@ mod tests {
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
||||||
|
|
||||||
// Non-pinned tabs in same pane
|
// Non-pinned tabs in same pane
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
add_labeled_item(&pane, "A", false, cx);
|
add_labeled_item(&pane, "A", false, cx);
|
||||||
add_labeled_item(&pane, "B", false, cx);
|
add_labeled_item(&pane, "B", false, cx);
|
||||||
add_labeled_item(&pane, "C", false, cx);
|
add_labeled_item(&pane, "C", false, cx);
|
||||||
|
@ -4705,7 +4706,7 @@ mod tests {
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
||||||
|
|
||||||
// No non-pinned tabs in same pane, non-pinned tabs in another pane
|
// No non-pinned tabs in same pane, non-pinned tabs in another pane
|
||||||
let pane1 = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane1 = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
let pane2 = workspace.update_in(cx, |workspace, window, cx| {
|
let pane2 = workspace.update_in(cx, |workspace, window, cx| {
|
||||||
workspace.split_pane(pane1.clone(), SplitDirection::Right, window, cx)
|
workspace.split_pane(pane1.clone(), SplitDirection::Right, window, cx)
|
||||||
});
|
});
|
||||||
|
|
|
@ -410,7 +410,10 @@ impl SerializedPaneGroup {
|
||||||
.await
|
.await
|
||||||
.log_err()?;
|
.log_err()?;
|
||||||
|
|
||||||
if pane.update(cx, |pane, _| pane.items_len() != 0).log_err()? {
|
if pane
|
||||||
|
.read_with(cx, |pane, _| pane.items_len() != 0)
|
||||||
|
.log_err()?
|
||||||
|
{
|
||||||
let pane = pane.upgrade()?;
|
let pane = pane.upgrade()?;
|
||||||
Some((
|
Some((
|
||||||
Member::Pane(pane.clone()),
|
Member::Pane(pane.clone()),
|
||||||
|
|
|
@ -2519,7 +2519,7 @@ impl Workspace {
|
||||||
});
|
});
|
||||||
cx.spawn(async move |cx| {
|
cx.spawn(async move |cx| {
|
||||||
let (worktree, path) = entry.await?;
|
let (worktree, path) = entry.await?;
|
||||||
let worktree_id = worktree.update(cx, |t, _| t.id())?;
|
let worktree_id = worktree.read_with(cx, |t, _| t.id())?;
|
||||||
Ok((
|
Ok((
|
||||||
worktree,
|
worktree,
|
||||||
ProjectPath {
|
ProjectPath {
|
||||||
|
@ -5147,7 +5147,7 @@ impl Workspace {
|
||||||
cx: &mut Context<Workspace>,
|
cx: &mut Context<Workspace>,
|
||||||
) -> Task<Result<Vec<Option<Box<dyn ItemHandle>>>>> {
|
) -> Task<Result<Vec<Option<Box<dyn ItemHandle>>>>> {
|
||||||
cx.spawn_in(window, async move |workspace, cx| {
|
cx.spawn_in(window, async move |workspace, cx| {
|
||||||
let project = workspace.update(cx, |workspace, _| workspace.project().clone())?;
|
let project = workspace.read_with(cx, |workspace, _| workspace.project().clone())?;
|
||||||
|
|
||||||
let mut center_group = None;
|
let mut center_group = None;
|
||||||
let mut center_items = None;
|
let mut center_items = None;
|
||||||
|
@ -6836,7 +6836,7 @@ pub fn create_and_open_local_file(
|
||||||
default_content: impl 'static + Send + FnOnce() -> Rope,
|
default_content: impl 'static + Send + FnOnce() -> Rope,
|
||||||
) -> Task<Result<Box<dyn ItemHandle>>> {
|
) -> Task<Result<Box<dyn ItemHandle>>> {
|
||||||
cx.spawn_in(window, async move |workspace, cx| {
|
cx.spawn_in(window, async move |workspace, cx| {
|
||||||
let fs = workspace.update(cx, |workspace, _| workspace.app_state().fs.clone())?;
|
let fs = workspace.read_with(cx, |workspace, _| workspace.app_state().fs.clone())?;
|
||||||
if !fs.is_file(path).await {
|
if !fs.is_file(path).await {
|
||||||
fs.create_file(path, Default::default()).await?;
|
fs.create_file(path, Default::default()).await?;
|
||||||
fs.save(path, &default_content(), Default::default())
|
fs.save(path, &default_content(), Default::default())
|
||||||
|
@ -7647,7 +7647,7 @@ mod tests {
|
||||||
workspace.update_in(cx, |workspace, window, cx| {
|
workspace.update_in(cx, |workspace, window, cx| {
|
||||||
workspace.add_item_to_active_pane(Box::new(item1.clone()), None, true, window, cx);
|
workspace.add_item_to_active_pane(Box::new(item1.clone()), None, true, window, cx);
|
||||||
});
|
});
|
||||||
item1.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(0)));
|
item1.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(0)));
|
||||||
|
|
||||||
// Adding an item that creates ambiguity increases the level of detail on
|
// Adding an item that creates ambiguity increases the level of detail on
|
||||||
// both tabs.
|
// both tabs.
|
||||||
|
@ -7659,8 +7659,8 @@ mod tests {
|
||||||
workspace.update_in(cx, |workspace, window, cx| {
|
workspace.update_in(cx, |workspace, window, cx| {
|
||||||
workspace.add_item_to_active_pane(Box::new(item2.clone()), None, true, window, cx);
|
workspace.add_item_to_active_pane(Box::new(item2.clone()), None, true, window, cx);
|
||||||
});
|
});
|
||||||
item1.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));
|
item1.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));
|
||||||
item2.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));
|
item2.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));
|
||||||
|
|
||||||
// Adding an item that creates ambiguity increases the level of detail only
|
// 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
|
// on the ambiguous tabs. In this case, the ambiguity can't be resolved so
|
||||||
|
@ -7673,9 +7673,9 @@ mod tests {
|
||||||
workspace.update_in(cx, |workspace, window, cx| {
|
workspace.update_in(cx, |workspace, window, cx| {
|
||||||
workspace.add_item_to_active_pane(Box::new(item3.clone()), None, true, window, cx);
|
workspace.add_item_to_active_pane(Box::new(item3.clone()), None, true, window, cx);
|
||||||
});
|
});
|
||||||
item1.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));
|
item1.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));
|
||||||
item2.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(3)));
|
item2.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(3)));
|
||||||
item3.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(3)));
|
item3.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
@ -7702,7 +7702,7 @@ mod tests {
|
||||||
let project = Project::test(fs, ["root1".as_ref()], cx).await;
|
let project = Project::test(fs, ["root1".as_ref()], cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
let worktree_id = project.update(cx, |project, cx| {
|
let worktree_id = project.update(cx, |project, cx| {
|
||||||
project.worktrees(cx).next().unwrap().read(cx).id()
|
project.worktrees(cx).next().unwrap().read(cx).id()
|
||||||
});
|
});
|
||||||
|
@ -8099,7 +8099,7 @@ mod tests {
|
||||||
|
|
||||||
cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
close.await.unwrap();
|
close.await.unwrap();
|
||||||
right_pane.update(cx, |pane, _| {
|
right_pane.read_with(cx, |pane, _| {
|
||||||
assert_eq!(pane.items_len(), 0);
|
assert_eq!(pane.items_len(), 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -8112,7 +8112,7 @@ mod tests {
|
||||||
let project = Project::test(fs, [], cx).await;
|
let project = Project::test(fs, [], cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
let item = cx.new(|cx| {
|
let item = cx.new(|cx| {
|
||||||
TestItem::new(cx).with_project_items(&[TestProjectItem::new(1, "1.txt", cx)])
|
TestItem::new(cx).with_project_items(&[TestProjectItem::new(1, "1.txt", cx)])
|
||||||
|
@ -8134,12 +8134,12 @@ mod tests {
|
||||||
|
|
||||||
// Deactivating the window saves the file.
|
// Deactivating the window saves the file.
|
||||||
cx.deactivate_window();
|
cx.deactivate_window();
|
||||||
item.update(cx, |item, _| assert_eq!(item.save_count, 1));
|
item.read_with(cx, |item, _| assert_eq!(item.save_count, 1));
|
||||||
|
|
||||||
// Re-activating the window doesn't save the file.
|
// Re-activating the window doesn't save the file.
|
||||||
cx.update(|window, _| window.activate_window());
|
cx.update(|window, _| window.activate_window());
|
||||||
cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
item.update(cx, |item, _| assert_eq!(item.save_count, 1));
|
item.read_with(cx, |item, _| assert_eq!(item.save_count, 1));
|
||||||
|
|
||||||
// Autosave on focus change.
|
// Autosave on focus change.
|
||||||
item.update_in(cx, |item, window, cx| {
|
item.update_in(cx, |item, window, cx| {
|
||||||
|
@ -8155,7 +8155,7 @@ mod tests {
|
||||||
// Blurring the item saves the file.
|
// Blurring the item saves the file.
|
||||||
item.update_in(cx, |_, window, _| window.blur());
|
item.update_in(cx, |_, window, _| window.blur());
|
||||||
cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
item.update(cx, |item, _| assert_eq!(item.save_count, 2));
|
item.read_with(cx, |item, _| assert_eq!(item.save_count, 2));
|
||||||
|
|
||||||
// Deactivating the window still saves the file.
|
// Deactivating the window still saves the file.
|
||||||
item.update_in(cx, |item, window, cx| {
|
item.update_in(cx, |item, window, cx| {
|
||||||
|
@ -8178,11 +8178,11 @@ mod tests {
|
||||||
|
|
||||||
// Delay hasn't fully expired, so the file is still dirty and unsaved.
|
// Delay hasn't fully expired, so the file is still dirty and unsaved.
|
||||||
cx.executor().advance_clock(Duration::from_millis(250));
|
cx.executor().advance_clock(Duration::from_millis(250));
|
||||||
item.update(cx, |item, _| assert_eq!(item.save_count, 3));
|
item.read_with(cx, |item, _| assert_eq!(item.save_count, 3));
|
||||||
|
|
||||||
// After delay expires, the file is saved.
|
// After delay expires, the file is saved.
|
||||||
cx.executor().advance_clock(Duration::from_millis(250));
|
cx.executor().advance_clock(Duration::from_millis(250));
|
||||||
item.update(cx, |item, _| assert_eq!(item.save_count, 4));
|
item.read_with(cx, |item, _| assert_eq!(item.save_count, 4));
|
||||||
|
|
||||||
// Autosave on focus change, ensuring closing the tab counts as such.
|
// Autosave on focus change, ensuring closing the tab counts as such.
|
||||||
item.update(cx, |item, cx| {
|
item.update(cx, |item, cx| {
|
||||||
|
@ -8203,7 +8203,7 @@ mod tests {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(!cx.has_pending_prompt());
|
assert!(!cx.has_pending_prompt());
|
||||||
item.update(cx, |item, _| assert_eq!(item.save_count, 5));
|
item.read_with(cx, |item, _| assert_eq!(item.save_count, 5));
|
||||||
|
|
||||||
// Add the item again, ensuring autosave is prevented if the underlying file has been deleted.
|
// Add the item again, ensuring autosave is prevented if the underlying file has been deleted.
|
||||||
workspace.update_in(cx, |workspace, window, cx| {
|
workspace.update_in(cx, |workspace, window, cx| {
|
||||||
|
@ -8217,7 +8217,7 @@ mod tests {
|
||||||
window.blur();
|
window.blur();
|
||||||
});
|
});
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
item.update(cx, |item, _| assert_eq!(item.save_count, 5));
|
item.read_with(cx, |item, _| assert_eq!(item.save_count, 5));
|
||||||
|
|
||||||
// Ensure autosave is prevented for deleted files also when closing the buffer.
|
// Ensure autosave is prevented for deleted files also when closing the buffer.
|
||||||
let _close_items = pane.update_in(cx, |pane, window, cx| {
|
let _close_items = pane.update_in(cx, |pane, window, cx| {
|
||||||
|
@ -8225,7 +8225,7 @@ mod tests {
|
||||||
});
|
});
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
assert!(cx.has_pending_prompt());
|
assert!(cx.has_pending_prompt());
|
||||||
item.update(cx, |item, _| assert_eq!(item.save_count, 5));
|
item.read_with(cx, |item, _| assert_eq!(item.save_count, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
@ -8241,8 +8241,8 @@ mod tests {
|
||||||
let item = cx.new(|cx| {
|
let item = cx.new(|cx| {
|
||||||
TestItem::new(cx).with_project_items(&[TestProjectItem::new(1, "1.txt", cx)])
|
TestItem::new(cx).with_project_items(&[TestProjectItem::new(1, "1.txt", cx)])
|
||||||
});
|
});
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
let toolbar = pane.update(cx, |pane, _| pane.toolbar().clone());
|
let toolbar = pane.read_with(cx, |pane, _| pane.toolbar().clone());
|
||||||
let toolbar_notify_count = Rc::new(RefCell::new(0));
|
let toolbar_notify_count = Rc::new(RefCell::new(0));
|
||||||
|
|
||||||
workspace.update_in(cx, |workspace, window, cx| {
|
workspace.update_in(cx, |workspace, window, cx| {
|
||||||
|
@ -8254,7 +8254,7 @@ mod tests {
|
||||||
.detach();
|
.detach();
|
||||||
});
|
});
|
||||||
|
|
||||||
pane.update(cx, |pane, _| {
|
pane.read_with(cx, |pane, _| {
|
||||||
assert!(!pane.can_navigate_backward());
|
assert!(!pane.can_navigate_backward());
|
||||||
assert!(!pane.can_navigate_forward());
|
assert!(!pane.can_navigate_forward());
|
||||||
});
|
});
|
||||||
|
@ -8266,7 +8266,7 @@ mod tests {
|
||||||
// Toolbar must be notified to re-render the navigation buttons
|
// Toolbar must be notified to re-render the navigation buttons
|
||||||
assert_eq!(*toolbar_notify_count.borrow(), 1);
|
assert_eq!(*toolbar_notify_count.borrow(), 1);
|
||||||
|
|
||||||
pane.update(cx, |pane, _| {
|
pane.read_with(cx, |pane, _| {
|
||||||
assert!(pane.can_navigate_backward());
|
assert!(pane.can_navigate_backward());
|
||||||
assert!(!pane.can_navigate_forward());
|
assert!(!pane.can_navigate_forward());
|
||||||
});
|
});
|
||||||
|
@ -8279,7 +8279,7 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(*toolbar_notify_count.borrow(), 2);
|
assert_eq!(*toolbar_notify_count.borrow(), 2);
|
||||||
pane.update(cx, |pane, _| {
|
pane.read_with(cx, |pane, _| {
|
||||||
assert!(!pane.can_navigate_backward());
|
assert!(!pane.can_navigate_backward());
|
||||||
assert!(pane.can_navigate_forward());
|
assert!(pane.can_navigate_forward());
|
||||||
});
|
});
|
||||||
|
@ -8305,7 +8305,7 @@ mod tests {
|
||||||
panel
|
panel
|
||||||
});
|
});
|
||||||
|
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
pane.update_in(cx, |pane, window, cx| {
|
pane.update_in(cx, |pane, window, cx| {
|
||||||
let item = cx.new(TestItem::new);
|
let item = cx.new(TestItem::new);
|
||||||
pane.add_item(Box::new(item), true, true, None, window, cx);
|
pane.add_item(Box::new(item), true, true, None, window, cx);
|
||||||
|
@ -8871,7 +8871,7 @@ mod tests {
|
||||||
|
|
||||||
// Emitting a ZoomIn event shows the panel as zoomed.
|
// Emitting a ZoomIn event shows the panel as zoomed.
|
||||||
panel_1.update(cx, |_, cx| cx.emit(PanelEvent::ZoomIn));
|
panel_1.update(cx, |_, cx| cx.emit(PanelEvent::ZoomIn));
|
||||||
workspace.update(cx, |workspace, _| {
|
workspace.read_with(cx, |workspace, _| {
|
||||||
assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));
|
assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));
|
||||||
assert_eq!(workspace.zoomed_position, Some(DockPosition::Left));
|
assert_eq!(workspace.zoomed_position, Some(DockPosition::Left));
|
||||||
});
|
});
|
||||||
|
@ -8880,7 +8880,7 @@ mod tests {
|
||||||
panel_1.update_in(cx, |panel, window, cx| {
|
panel_1.update_in(cx, |panel, window, cx| {
|
||||||
panel.set_position(DockPosition::Right, window, cx)
|
panel.set_position(DockPosition::Right, window, cx)
|
||||||
});
|
});
|
||||||
workspace.update(cx, |workspace, _| {
|
workspace.read_with(cx, |workspace, _| {
|
||||||
assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));
|
assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));
|
||||||
|
|
||||||
assert_eq!(workspace.zoomed_position, Some(DockPosition::Right));
|
assert_eq!(workspace.zoomed_position, Some(DockPosition::Right));
|
||||||
|
@ -8907,7 +8907,7 @@ mod tests {
|
||||||
// If focus is transferred to another view that's not a panel or another pane, we still show
|
// If focus is transferred to another view that's not a panel or another pane, we still show
|
||||||
// the panel as zoomed.
|
// the panel as zoomed.
|
||||||
focus_other_view(cx);
|
focus_other_view(cx);
|
||||||
workspace.update(cx, |workspace, _| {
|
workspace.read_with(cx, |workspace, _| {
|
||||||
assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));
|
assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));
|
||||||
assert_eq!(workspace.zoomed_position, Some(DockPosition::Right));
|
assert_eq!(workspace.zoomed_position, Some(DockPosition::Right));
|
||||||
});
|
});
|
||||||
|
@ -8916,7 +8916,7 @@ mod tests {
|
||||||
workspace.update_in(cx, |_workspace, window, cx| {
|
workspace.update_in(cx, |_workspace, window, cx| {
|
||||||
cx.focus_self(window);
|
cx.focus_self(window);
|
||||||
});
|
});
|
||||||
workspace.update(cx, |workspace, _| {
|
workspace.read_with(cx, |workspace, _| {
|
||||||
assert_eq!(workspace.zoomed, None);
|
assert_eq!(workspace.zoomed, None);
|
||||||
assert_eq!(workspace.zoomed_position, None);
|
assert_eq!(workspace.zoomed_position, None);
|
||||||
});
|
});
|
||||||
|
@ -8924,21 +8924,21 @@ mod tests {
|
||||||
// If focus is transferred again to another view that's not a panel or a pane, we won't
|
// If focus is transferred again to another view that's not a panel or a pane, we won't
|
||||||
// show the panel as zoomed because it wasn't zoomed before.
|
// show the panel as zoomed because it wasn't zoomed before.
|
||||||
focus_other_view(cx);
|
focus_other_view(cx);
|
||||||
workspace.update(cx, |workspace, _| {
|
workspace.read_with(cx, |workspace, _| {
|
||||||
assert_eq!(workspace.zoomed, None);
|
assert_eq!(workspace.zoomed, None);
|
||||||
assert_eq!(workspace.zoomed_position, None);
|
assert_eq!(workspace.zoomed_position, None);
|
||||||
});
|
});
|
||||||
|
|
||||||
// When the panel is activated, it is zoomed again.
|
// When the panel is activated, it is zoomed again.
|
||||||
cx.dispatch_action(ToggleRightDock);
|
cx.dispatch_action(ToggleRightDock);
|
||||||
workspace.update(cx, |workspace, _| {
|
workspace.read_with(cx, |workspace, _| {
|
||||||
assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));
|
assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));
|
||||||
assert_eq!(workspace.zoomed_position, Some(DockPosition::Right));
|
assert_eq!(workspace.zoomed_position, Some(DockPosition::Right));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Emitting a ZoomOut event unzooms the panel.
|
// Emitting a ZoomOut event unzooms the panel.
|
||||||
panel_1.update(cx, |_, cx| cx.emit(PanelEvent::ZoomOut));
|
panel_1.update(cx, |_, cx| cx.emit(PanelEvent::ZoomOut));
|
||||||
workspace.update(cx, |workspace, _| {
|
workspace.read_with(cx, |workspace, _| {
|
||||||
assert_eq!(workspace.zoomed, None);
|
assert_eq!(workspace.zoomed, None);
|
||||||
assert_eq!(workspace.zoomed_position, None);
|
assert_eq!(workspace.zoomed_position, None);
|
||||||
});
|
});
|
||||||
|
@ -8961,7 +8961,7 @@ mod tests {
|
||||||
let project = Project::test(fs, [], cx).await;
|
let project = Project::test(fs, [], cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
let dirty_regular_buffer = cx.new(|cx| {
|
let dirty_regular_buffer = cx.new(|cx| {
|
||||||
TestItem::new(cx)
|
TestItem::new(cx)
|
||||||
|
@ -9109,7 +9109,7 @@ mod tests {
|
||||||
let project = Project::test(fs, [], cx).await;
|
let project = Project::test(fs, [], cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
let dirty_regular_buffer = cx.new(|cx| {
|
let dirty_regular_buffer = cx.new(|cx| {
|
||||||
TestItem::new(cx)
|
TestItem::new(cx)
|
||||||
|
@ -9199,7 +9199,7 @@ mod tests {
|
||||||
let project = Project::test(fs, [], cx).await;
|
let project = Project::test(fs, [], cx).await;
|
||||||
let (workspace, cx) =
|
let (workspace, cx) =
|
||||||
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));
|
||||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||||
|
|
||||||
let dirty_regular_buffer = cx.new(|cx| {
|
let dirty_regular_buffer = cx.new(|cx| {
|
||||||
TestItem::new(cx)
|
TestItem::new(cx)
|
||||||
|
|
|
@ -880,7 +880,7 @@ impl Worktree {
|
||||||
.await
|
.await
|
||||||
.map(CreatedEntry::Included),
|
.map(CreatedEntry::Included),
|
||||||
None => {
|
None => {
|
||||||
let abs_path = this.update(cx, |worktree, _| {
|
let abs_path = this.read_with(cx, |worktree, _| {
|
||||||
worktree
|
worktree
|
||||||
.absolutize(&path)
|
.absolutize(&path)
|
||||||
.with_context(|| format!("absolutizing {path:?}"))
|
.with_context(|| format!("absolutizing {path:?}"))
|
||||||
|
@ -2027,7 +2027,7 @@ impl LocalWorktree {
|
||||||
cx.spawn(async move |this, cx| {
|
cx.spawn(async move |this, cx| {
|
||||||
refresh.recv().await;
|
refresh.recv().await;
|
||||||
log::trace!("refreshed entry {path:?} in {:?}", t0.elapsed());
|
log::trace!("refreshed entry {path:?} in {:?}", t0.elapsed());
|
||||||
let new_entry = this.update(cx, |this, _| {
|
let new_entry = this.read_with(cx, |this, _| {
|
||||||
this.entry_for_path(path)
|
this.entry_for_path(path)
|
||||||
.cloned()
|
.cloned()
|
||||||
.context("reading path after update")
|
.context("reading path after update")
|
||||||
|
@ -2274,7 +2274,7 @@ impl RemoteWorktree {
|
||||||
.await
|
.await
|
||||||
.map(CreatedEntry::Included),
|
.map(CreatedEntry::Included),
|
||||||
None => {
|
None => {
|
||||||
let abs_path = this.update(cx, |worktree, _| {
|
let abs_path = this.read_with(cx, |worktree, _| {
|
||||||
worktree
|
worktree
|
||||||
.absolutize(&new_path)
|
.absolutize(&new_path)
|
||||||
.with_context(|| format!("absolutizing {new_path:?}"))
|
.with_context(|| format!("absolutizing {new_path:?}"))
|
||||||
|
@ -5082,7 +5082,7 @@ impl WorktreeModelHandle for Entity<Worktree> {
|
||||||
let file_name = "fs-event-sentinel";
|
let file_name = "fs-event-sentinel";
|
||||||
|
|
||||||
let tree = self.clone();
|
let tree = self.clone();
|
||||||
let (fs, root_path) = self.update(cx, |tree, _| {
|
let (fs, root_path) = self.read_with(cx, |tree, _| {
|
||||||
let tree = tree.as_local().unwrap();
|
let tree = tree.as_local().unwrap();
|
||||||
(tree.fs.clone(), tree.abs_path().clone())
|
(tree.fs.clone(), tree.abs_path().clone())
|
||||||
});
|
});
|
||||||
|
@ -5094,7 +5094,7 @@ impl WorktreeModelHandle for Entity<Worktree> {
|
||||||
|
|
||||||
let mut events = cx.events(&tree);
|
let mut events = cx.events(&tree);
|
||||||
while events.next().await.is_some() {
|
while events.next().await.is_some() {
|
||||||
if tree.update(cx, |tree, _| tree.entry_for_path(file_name).is_some()) {
|
if tree.read_with(cx, |tree, _| tree.entry_for_path(file_name).is_some()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5103,7 +5103,7 @@ impl WorktreeModelHandle for Entity<Worktree> {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
while events.next().await.is_some() {
|
while events.next().await.is_some() {
|
||||||
if tree.update(cx, |tree, _| tree.entry_for_path(file_name).is_none()) {
|
if tree.read_with(cx, |tree, _| tree.entry_for_path(file_name).is_none()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5128,7 +5128,7 @@ impl WorktreeModelHandle for Entity<Worktree> {
|
||||||
let file_name = "fs-event-sentinel";
|
let file_name = "fs-event-sentinel";
|
||||||
|
|
||||||
let tree = self.clone();
|
let tree = self.clone();
|
||||||
let (fs, root_path, mut git_dir_scan_id) = self.update(cx, |tree, _| {
|
let (fs, root_path, mut git_dir_scan_id) = self.read_with(cx, |tree, _| {
|
||||||
let tree = tree.as_local().unwrap();
|
let tree = tree.as_local().unwrap();
|
||||||
let local_repo_entry = tree
|
let local_repo_entry = tree
|
||||||
.git_repositories
|
.git_repositories
|
||||||
|
|
|
@ -1535,10 +1535,10 @@ fn open_local_file(
|
||||||
cx.spawn_in(window, async move |workspace, cx| {
|
cx.spawn_in(window, async move |workspace, cx| {
|
||||||
// Check if the file actually exists on disk (even if it's excluded from worktree)
|
// Check if the file actually exists on disk (even if it's excluded from worktree)
|
||||||
let file_exists = {
|
let file_exists = {
|
||||||
let full_path =
|
let full_path = worktree
|
||||||
worktree.update(cx, |tree, _| tree.abs_path().join(settings_relative_path))?;
|
.read_with(cx, |tree, _| tree.abs_path().join(settings_relative_path))?;
|
||||||
|
|
||||||
let fs = project.update(cx, |project, _| project.fs().clone())?;
|
let fs = project.read_with(cx, |project, _| project.fs().clone())?;
|
||||||
let file_exists = fs
|
let file_exists = fs
|
||||||
.metadata(&full_path)
|
.metadata(&full_path)
|
||||||
.await
|
.await
|
||||||
|
@ -1550,7 +1550,7 @@ fn open_local_file(
|
||||||
|
|
||||||
if !file_exists {
|
if !file_exists {
|
||||||
if let Some(dir_path) = settings_relative_path.parent() {
|
if let Some(dir_path) = settings_relative_path.parent() {
|
||||||
if worktree.update(cx, |tree, _| tree.entry_for_path(dir_path).is_none())? {
|
if worktree.read_with(cx, |tree, _| tree.entry_for_path(dir_path).is_none())? {
|
||||||
project
|
project
|
||||||
.update(cx, |project, cx| {
|
.update(cx, |project, cx| {
|
||||||
project.create_entry((tree_id, dir_path), true, cx)
|
project.create_entry((tree_id, dir_path), true, cx)
|
||||||
|
@ -1560,7 +1560,7 @@ fn open_local_file(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if worktree.update(cx, |tree, _| {
|
if worktree.read_with(cx, |tree, _| {
|
||||||
tree.entry_for_path(settings_relative_path).is_none()
|
tree.entry_for_path(settings_relative_path).is_none()
|
||||||
})? {
|
})? {
|
||||||
project
|
project
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue